• I’ve been searching and could not get my hands on the correct code or method for doing this:

    I currently upload only 1 image (which I consider a feature image) into my gallery on my post. How do I pull this into my RSS feed?

    I’m sure I need a function and then I need to put it into the RSS feed php, but I’m not sure which one, how to format that or where it needs to go in there.

    I’m usually pretty good at figuring these things out and try to withhold my posting unless its the very last option. This one just has me stumped.

    Thanks for any advice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Here’s how to get the first attachment.

    // If is not the Featured Thumbnail
    
    $args = array(
        'post_type' => 'attachment',
        'exclude' => get_post_thumbnail_id(the-post-id)
    );
    
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
    
       // echo them here
    
        }
    }
    
    //If is the Featured Thumbnail
    
    $image = wp_get_attachment_image_src( get_post_thumbnail_id(the-post-id), 'single-post-thumbnail' ); 
    
       $imageURL = $image[0];

    http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

    Thread Starter isserdude

    (@isserdude)

    Thanks. How would I place that into the RSS feed?

    function add_thumb_to_RSS($content) {
       global $post;
       if ( has_post_thumbnail( $post->ID ) ){
          $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
       }
       return $content;
    }
    add_filter('the_excerpt_rss', 'add_thumb_to_RSS');
    add_filter('the_content_feed', 'add_thumb_to_RSS');

    To your functions.php

    Where would you place the first bit of code? I got that the second part goes in the functions.php, but I tried to add the first bit above that second bit in fucntions.php and it threw an error.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pulling First Gallery Image into RSS Feed’ is closed to new replies.