php - Can I add the post featured image to a specific RSS feed?

I'm currently using the following code:function featuredtoRSS($content) {global $post;if ( has_post_thumbnail( $pos

I'm currently using the following code:

function featuredtoRSS($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');

Which does work, but I'm running a few MailChimp RSS emails campaigns and am needing one RSS feed to show the featured image (articles feed) and one where I don't want to show the featured image.

My thought is to do this by category, possibly?

Let me know if more clarification is needed!

Thanks!

I'm currently using the following code:

function featuredtoRSS($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');

Which does work, but I'm running a few MailChimp RSS emails campaigns and am needing one RSS feed to show the featured image (articles feed) and one where I don't want to show the featured image.

My thought is to do this by category, possibly?

Let me know if more clarification is needed!

Thanks!

Share Improve this question edited Aug 27, 2019 at 15:21 Kenan Philips asked Aug 27, 2019 at 15:16 Kenan PhilipsKenan Philips 133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

WPBeginner has a nice article " How to Create Custom RSS Feeds in WordPress" that addresses this from a manageable perspective.

They cover creating custom feeds, and using theme templates to customize what your feeds publish.

Take a look.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745206931a4616637.html

相关推荐

  • php - Can I add the post featured image to a specific RSS feed?

    I'm currently using the following code:function featuredtoRSS($content) {global $post;if ( has_post_thumbnail( $pos

    10小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信