注册shortcode, 理想的插件或函数。php,如果必须的话。
add_shortcode(\'thumbnail\', \'thumbnail_in_content\');
function thumbnail_in_content($atts) {
global $post;
return get_the_post_thumbnail($post->ID);
}
添加
shortcode 向您发布内容。
[thumbnail]
如果需要更多功能,请参阅
this post 或者
pastebin.
<小时>
ADDING CAPTIONS AND LINKS
add_shortcode(\'thumbnail\', \'thumbnail_with_caption_shortcode\');
function thumbnail_with_caption_shortcode($atts) {
global $post;
// Image to display
$thumbnail = get_the_post_thumbnail($post->ID);
// ID of featured image
$thumbnail_id = get_post_thumbnail_id();
// Caption from featured image\'s WP_Post
$caption = get_post($thumbnail_id)->post_excerpt;
// Link to attachment page
$link = get_permalink($thumbnail_id);
// Final output
return \'<div class="featured-image">\'
. \'<a href="\' . $link . \'">\'
. $thumbnail
. \'<span class="caption">\' . $caption . \'</span>\'
. \'</a>\'
. \'</div>\';
}
RESOURCES