当挂钩可以修改使用时,您不需要编辑WordPress核心文件,也不需要这样做the_excerpt_rss
和the_content_feed
筛选以在提要中添加缩略图或自定义链接。
add_filter( \'the_excerpt_rss\', \'insert_thumbnail_into_feed\' );
add_filter( \'the_content_feed\', \'insert_thumbnail_into_feed\' );
function insert_thumbnail_into_feed() {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
// replace thumbnail with yours
$content = \'<p>\' .get_the_post_thumbnail( $post->ID, \'thumbnail\' ) .\'</p>\';
}
// get post content and replace feed content with
// you can also limit/filter the content to exclude shortcodes and html code etc.
$content .= \'<p>\' .get_the_content() .\'</p>\';
return $content;
}
编辑:将此代码放置在主题的函数中。php