我使用以下内容将帖子缩略图输出为地图上的标记。
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, array( 100, 100), true);
$thumb_url = $thumb_url_array[0];
但是,我想在缩略图中添加一个类。我试过了array(\'class\' => \'your-class-name\')
但那没用。
我使用以下内容将帖子缩略图输出为地图上的标记。
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, array( 100, 100), true);
$thumb_url = $thumb_url_array[0];
但是,我想在缩略图中添加一个类。我试过了array(\'class\' => \'your-class-name\')
但那没用。
使用wp_get_attachment_image()
如果要设置类属性,请改为。
示例:
$image = wp_get_attachment_image(
get_post_thumbnail_id(),
array(100, 100),
true,
array(\'class\' => \'your-class-name\')
);
//returns the HTML for the attachment
echo $image;
上述函数返回HTMLimg
标签:<img src="http://example.com/path/to/image.jpg" class="your-class-name"/>