WordPress在RSS订阅里显示文章缩略图
发布时间:2020-12-14 14:12:32 所属栏目:wordpress 来源:网络整理
导读:通过WordPress 2.9引入的get_the_post_thumbnail()函数,我们可以在文章里显示缩略图。而下面的这段代码,则能够让文章缩略图直接显示在RSS订阅中。 操作很简单,把下面的代码复制到主题的functions.php文件,然后保存就可以了。 function diw_post_thumbnai
通过WordPress 2.9引入的get_the_post_thumbnail()函数,我们可以在文章里显示缩略图。而下面的这段代码,则能够让文章缩略图直接显示在RSS订阅中。 操作很简单,把下面的代码复制到主题的functions.php文件,然后保存就可以了。 function diw_post_thumbnail_feeds($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content; } return $content; } //32网教76程 add_filter('the_excerpt_rss','diw_post_thumbnail_feeds'); add_filter('the_content_feed','diw_post_thumbnail_feeds'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |