Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

is there any way to show an image for RSS feess in my wordpress page... it os because currently defaul wordpress RSS feeds will only show a text of other feeds from other site..how can i make my site show a thumb image of rss feeds of th other sites..below are example of the rss feeds on my site. plizzz help me.i really needs a help from all of u guys....

alt text

share|improve this question
    
Which version of Wordpress are you using? –  jsalonen Oct 17 '10 at 16:42
    
i'm using wordpress 3.0 –  Beginner Pogrammer Oct 17 '10 at 16:48
    
Questions like this should be sent to wordpress.stackexchange.com –  Andy Lester Oct 18 '10 at 4:07
add comment

migrated from stackoverflow.com Oct 18 '10 at 10:14

This question came from our site for professional and enthusiast programmers.

2 Answers

Yes, you can "hook" into the RSS feed and call 1 attachment (thumbmail)

Add this line to your functions.php file...

This example will add 3 thumbs, but simply change the "numberposts" to your desired amount...

/* Adding 3 thumbs to the top of the post on RSS */
    function rss_custom_format($content) {
    //prob uneccessary but checking that it is in fact a feed
    if(is_feed()){

       global $post;
       if(!$post->ID){return;}

       $args = array(
            'post_type' => 'attachment',
            'numberposts' => 3,
            'orderby'    => 'menu_order ID',
            'post_parent' => $post->ID,
            'post_mime_type' => 'image',
            'order' => 'ASC'
        ); 


       $attachments = get_posts($args);

       if($attachments){
       $thumb = '';    
       foreach($attachments as $attachment){
        $thumb .= wp_get_attachment_link($attachment->ID,'thumbnail','true').' ';
       }

     } 
    }
    $thumb .= '<div style="clear:both; width:100%;"></div>';
    $content = preg_replace('`\[[^\]]*\]`','',$content);
    $more = '<a href="'.get_permalink($post->ID).'">Read More ...</a>';
    return $thumb.$content.$more;

    }

    add_filter('the_content_rss','rss_custom_format');
    add_filter('the_excerpt_rss','rss_custom_format');
share|improve this answer
    
Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\xampp\blog\wp-content\themes\structure\functions.php on line 83 --> this is error happen when i put in on my theme functions.php –  Beginner Pogrammer Oct 18 '10 at 3:58
    
That usually means you're missing a closing ';' or a '}' somewhere in your code. Add one more '}' to the very end. –  awats Oct 18 '10 at 4:01
    
already put it and the same problem happen –  Beginner Pogrammer Oct 18 '10 at 4:05
    
can you paste in line 83? That's the most likey the culprit. I have used this code on several sites so I know it's good. I think you need one last '}' –  awats Oct 18 '10 at 4:07
    
/* Adding 3 thumbs to the top of the post on RSS */ function rss_custom_format($content) { //prob uneccessary but checking that it is in fact a feed if(is_feed()){ global $post; if(!$post->ID){return;} $args = array( 'post_type' => 'attachment', 'numberposts' => 3, 'orderby' => 'menu_order ID', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'order' => 'ASC' ); $attachments = get_posts($args); if($attachments){ $thumb = ''; foreach($attachments as $attachment){ $thumb .= wp_get_attachment_link($attachment->ID,'thumbnail','true').' '; } ?> –  Beginner Pogrammer Oct 18 '10 at 4:12
show 3 more comments

Your feed is hacked. This is not programming related, go ask on server fault. See http://wordpress.org/support/topic/blog-was-hacked-rss-issue-but-now-i-get-garbled-text-what-does-this-mean

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.