郁金香媒体

创业想法

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 上的新短片 👉 致力于最佳油籽健康的培训终于以音频格式提供 https://buff.ly/3xo9fTS
https://buff.ly/43DkrYR

Blooness 的新短裤 👉 如果只能服用一种补充剂,那就是镁(以及维生素 D)。市场上最好的多种维生素的完整指南仍然可以在这里免费访问https://buff.ly/49bHqvp
https://buff.ly/49c3rKK

Blooness 的新短片 👉 关于 # 蛋白质的最新 Blooness 培训以音频格式提供 https://buff.ly/4aijbMW
https://buff.ly/3TP67cB

装载更多

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

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

发表回复

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

zh_CNZH