[Support request] Featured image in RSS

Home Forums Support [Support request] Featured image in RSS

Home Forums Support Featured image in RSS

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1439524
    septiady

    How do i add featured image in RSS? Google News doesnt show the correct image. I searched that you have to add image code in rss.

    thx for the help

    #1439543
    David
    Staff
    Customer Support

    Hi there,

    maybe the code Tom provides here will help:

    https://generatepress.com/forums/topic/no-image-captions-in-rss-feed/#post-1192398

    #1441083
    septiady

    i am a noob about this. where do i post this code? thank for the help. can you guide me step by step like.

    element>?>?>?

    #1441271
    David
    Staff
    Customer Support

    Sorry should have provided this article on how to add PHP:

    https://docs.generatepress.com/article/adding-php/

    TLDR: Options:

    1. Are you using a Child Theme ? If you are then add the code into your child themes functions.php

    2. If you are not using a child theme – then install the Code Snippets plugin:
    https://wordpress.org/plugins/code-snippets/

    2.1 Dashboard > Snippets > New Snippet
    2.2 Paste in the code.
    2.3 Click Save and Activate

    #1441359
    septiady

    WP Beginenr
    function rss_post_thumbnail($content) {
    global $post;
    if(has_post_thumbnail($post->ID)) {
    $content = ‘<p>’ . get_the_post_thumbnail($post->ID) .
    ‘</p>’ . get_the_content();
    }
    return $content;
    }
    add_filter(‘the_excerpt_rss’, ‘rss_post_thumbnail’);
    add_filter(‘the_content_feed’, ‘rss_post_thumbnail’);

    OR TOM’S

    add_filter( ‘the_content’, ‘featured_image_in_feed’ );
    function featured_image_in_feed( $content ) {
    global $post;
    if( is_feed() ) {
    if ( has_post_thumbnail( $post->ID ) ){
    $output = get_the_post_thumbnail( $post->ID, ‘medium’, array( ‘style’ => ‘float:right; margin:0 0 10px 10px;’ ) );
    $output .= ‘

    ‘ . get_the_post_thumbnail_caption( $post->ID ) . ‘

    ‘;
    $content = $output . $content;
    }
    }
    return $content;
    }

    Alright, i do not know any coding, i found this in wpbeginner. So which code do i use? i am using generatepress read theme.

    Sorry for any stupid question. Thank you

    #1441365
    David
    Staff
    Customer Support

    Either of WP Beginner or Toms should work. The only difference is that Toms will also output the Image Caption if one exists.

    Make sure you copy the code from the original topic or the WP Beginners sites 🙂

    #1448160
    septiady

    tHANK YOU.

    This should my my last reply:

    Which should i choose

    View post on imgur.com

    Thank you^^

    #1448359
    David
    Staff
    Customer Support

    Leave it as the default ‘Run snippet everywhere’

    #1448429
    septiady

    priority is 10?

    thank you man, generatepress has awesome support^^

    #1448485
    David
    Staff
    Customer Support

    Yes, priority can be left at 10

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.