如果您使用的是本机RSS源,则可以通过过滤器挂钩添加帖子缩略图:
function insertThumbnailRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = \'\' . get_the_post_thumbnail( $post->ID, \'thumbnail\', array( \'alt\' => get_the_title(), \'title\' => get_the_title(), \'style\' => \'float:right;\' ) ) . \'\' . $content;
}
return $content;
}
add_filter(\'the_excerpt_rss\', \'insertThumbnailRSS\');
add_filter(\'the_content_feed\', \'insertThumbnailRSS\');
但如果要创建自定义提要,则可以使用\\u post\\u缩略图添加图像,例如:
<li>
<p><?php echo $item->get_date(\'j F Y\'); ?></p>
<a target="_blank" href=\'<?php echo esc_url( $item->get_permalink() ); ?>\'title=\'<?php echo \'Posted \'.$item->get_date(\'j F Y | g:i a\'); ?>\'>
<strong> <?php echo esc_html( $item->get_title() ); ?> </strong></a>
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?>
}</li>