get paid to paste

WordPress thumbnails in RSS feed with link...

<?php

// thumbnails is RSS, linking them to the associated post
function wptuts_feedimgs($content) {
	global $post, $wpdb; 
	$attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' 
AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");

		$content =  '<a href='. get_permalink($post->ID) .'><img src='. wp_get_attachment_url($attachment_id) .' /></a>' . $content;

	return $content;
	
}
add_filter('the_excerpt_rss', 'wptuts_feedimgs'); // for feed excerpts
add_filter('the_content_feed', 'wptuts_feedimgs'); // for full feeds
?>

Pasted: Sep 18, 2010, 10:39:14 pm
Views: 100