get paid to paste

Attachment images in WordPress feed

<?php

function mf_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='. the_permalink($post->ID) .'><img src='. wp_get_attachment_url($attachment_id) .' /></a>' . $content;

	return $content;
	
}
add_filter('the_content_feed', 'mf_feedimgs');
?>

Pasted: Sep 7, 2010, 6:26:59 pm
Views: 13