这是link 我找到了解决办法。如何在WordPress提要中显示特色帖子缩略图
将此代码段粘贴到主题函数中。php文件
// display featured post thumbnails in WordPress feeds
function wcs_post_thumbnails_in_feeds( $content ) {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
//if you want to show thumbnail image
$content = \'<figure>\' . get_the_post_thumbnail( $post->ID, \'thumbnail\' ) . \'</figure>\' . $content;
// if you want to show full image
//$content = \'<p>\' . get_the_post_thumbnail( $post->ID,\'full\' ) . \'</p>\' . $content;
//if you want to custom image using add_image_size()
//$content = \'<figure>\' . get_the_post_thumbnail( $post->ID, \'custom-image-size\' ) . \'</figure>\' . $content;
}
return $content;
}
add_filter( \'the_excerpt_rss\', \'wcs_post_thumbnails_in_feeds\' );
add_filter( \'the_content_feed\', \'wcs_post_thumbnails_in_feeds\' );
这是如何显示外部链接图像的概念。你如何获取外部图像,它就在你身上。
它显示的是同一张照片。只需更改每篇文章的图像链接。例如:src=“..image\\u url.”
function rss_feed_from_external_link( $content ) {
global $post;
$content = \'<figure><img width="150" height="128" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" sizes="100vw" /></figure>\' . $content;
return $content;
}
add_filter( \'the_excerpt_rss\', \'rss_feed_from_external_link\' );
add_filter( \'the_content_feed\', \'rss_feed_from_external_link\' );
显示自定义字段的图像。
add_filter(\'the_content\', \'custom_fields_for_feeds\');
add_filter(\'the_meta\',\'custom_files_for_feed\');
function custom_fields_for_feeds( $content ) {
global $post;
global $post;
// Get the custom fields ***
// Checks for thumbnail
$image = get_post_meta($post->ID, \'Thumbnail\', $single = true);
// Checks for thumbnail alt text
$image_alt = get_post_meta($post->ID, \'Thumbnail Alt\', $single = true);
if($image_alt == \'\') { $image_alt = \'This image has no alt text\'; }
if($image !== \'\') {
$content = \'<figure><img src="\'.$image.\'" alt="\'.$image_alt.\'" /></figure>\' . $content;
return $content;
}
else {
$content = $content;
return $content;
}
add_filter(\'the_content\', \'custom_fields_for_feeds\');
add_filter(\'the_meta\',\'custom_files_for_feed\');
您还可以使用自定义图像字段显示在RSS提要中。
让我知道你没有解决你的问题。