Used to display the last post and image from a specific category, this can be useful for latest news on a homepage or latest posts in a sidebar.
<?php
query_posts('cat=3&showposts=1'); // replace 123 by category ID of "Headline"
if(have_posts()) : the_post(); $images = get_children(array( 'post_parent' = --> get_the_id(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'ID',
'order' => 'ASC',
'numberposts' => 1
));
foreach((array)$images as $key => $image){
echo wp_get_attachment_image($key);
}
the_title();
the_excerpt();
endif;
wp_reset_query();
?>
Recent Comments