WordPress.org

Forums

I want my images to show in RSS feed but doesn't work (7 posts)

  1. femkedam
    Member
    Posted 1 year ago #

    Hi,
    I'm trying to figure out how I can get my images to show up in the RSS feed. I already installed a plugin but it doesn't seem to work.
    I don't want the whole post to show in the RSS, just the first image.
    Also now I don't see any pictures in my bloglovin profile.

    Hope someone can help me with a simple solution for this.

    Thanks in advance!
    Femke

    My blog: http://www.somewheresomethingblog.com

  2. gerald@WPcustoms
    Member
    Posted 1 year ago #

    Maby this helps:
    [ link deleted ]

    it shows the post's featured image in your rss feed.

  3. Gerald? Can you please refrain from sending users to your site that way? It helps people more and as you're probably aware sending users to your site can and has been abused.

    You can easily share your code like so.

    /**
     * Snippet Name: show featured image in rss feed
     */
     function wpc_featured_image_in_feed( $content ) {
        global $post;
        if( is_feed() ) {
            if ( has_post_thumbnail( $post->ID ) ){
                $output = get_the_post_thumbnail( $post->ID, 'medium' ) );
                $content = $output . $content;
            }
        }
        return $content;
    }
    add_filter( 'the_content_feed', 'wpc_featured_image_in_feed' );
  4. Also (and I'm replying again to generate that email) I am not attributing any bad motives and I do applaud you helping here! But please do keep it here when possible.

  5. gerald@WPcustoms
    Member
    Posted 1 year ago #

    Hi Jan,
    sure no problem. Sorry.
    I just added exactly that function minutes before reading that post here.
    And as you see my site's concept is excactly the opposite of harming any WordPress user :)
    But sure I understand your point.

  6. femkedam
    Member
    Posted 1 year ago #

    Thanks, I tried it with this code (it's in my childtheme) but now I only get codes when I go to my feed: http://www.somewheresomethingblog.com/feed/
    What am I doing wrong?

  7. gerald@WPcustoms
    Member
    Posted 1 year ago #

    sorry, there's one bracket too much - replace the line with this:
    $output = get_the_post_thumbnail( $post->ID, 'medium' );

    I tried it again and it returns the proper img data which should look similar to this:

    <content:encoded>
    <![CDATA[
    <img width="300" height="224" src="your-img-url" class="attachment-medium wp-post-image" alt="">
    ]]>
    </content:encoded>

    please try to update your latest post (which has a featured image) and refresh your feed url.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags