Monday 8 August 2011

Wordpress - How to show Images on your posts feed

 - If we need to get images in posts feed.we need to add the following code in Functions.php file.


function show_image_feed($content) {

global $post;
$args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post->ID
);

$attachment = get_posts($args);

if ($attachment) {

 $content =  wp_get_attachment_image($attachment[0]->ID, 'medium') .'<p>'. $content . '</p>' . '<br />';
}

return $content;

}

add_filter('the_excerpt_rss', 'show_image_feed'); // for feed excerpts
add_filter('the_content_feed', 'show_image_feed'); // for full feeds