郁金香媒体

创业想法

WordPress 技巧:如何在 RSS 源上显示特色图像

下面是一个简单的代码,可让您在 RSS 提要中显示帖子的特色图像……

…这样,您的特色图像将显示在您的所有社交源上,例如 Facebook。

请将此代码添加到您的 函数.php 文件:

  • 使用此代码显示特色图像:

函数 imageRSS($content) {
全球$post;
if (has_post_thumbnail($post->ID)){
$内容 = » . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float: right; margin:0 0 10px 10px;' ) ) . » 。 $含量;
}
返回$内容;
}

add_filter('the_excerpt_rss', 'imageRSS');
add_filter('the_content_feed', 'imageRSS');

  • 如果您有以下代码,请使用此代码 获取图像 插件,以便在帖子中没有特色图片时扫描图片:

函数 imageRSS($content) {
全球$post;
if (has_post_thumbnail($post->ID)){
$内容 = » . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float: right; margin:0 0 10px 10px;' ) ) . » 。 $含量;
}
别的 {
$内容 = » . get_the_image(array('width' => 150, 'image_scan' => true , 'image_class' => », 'meta_key' => array( 'Thumbnail', 'thumbnail' ))) 。 » 。 $含量;
}
返回$内容;
}

add_filter('the_excerpt_rss', 'imageRSS');
add_filter('the_content_feed', 'imageRSS');

函数 show_image_feed($content) {

全球$post;
$args = 数组(
'post_type' => '附件',
'numberposts' => 1,
'post_status' => 空,
'post_parent' => $post->ID
);

$attachment = get_posts($args);

如果(1TP4附件){

$内容='

'。 $内容。 '
ID)。' >>>阅读其余部分。'; } 返回$内容; add_filter('the_excerpt_rss', 'show_image_feed');

 

我最新的推文

Blooness 上的新短裤 👉 批量重新启动性欲 -> 阳光、维生素 D、地中海酮饮食、蛋白质、书籍、玩笑、散步、HIIT 和无低热量饮食。
https://buff.ly/445PWvc

Blooness 的新短裤 👉 改善睡眠 -> 早上让自己接触光线,限制戴墨镜,运动时弄湿衬衫,喝无咖啡因饮料,睡前最多 3 小时进食,进行消化散步并服用一些褪黑激素
https://buff.ly/440weAJ

装载更多

不要错过通过电子邮件发送的商业建议

没有垃圾邮件,只有新内容发布时的电子邮件.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

zh_CNZH