I would like to display
- the most recent post
- AND the number of comments for that particular post
- on my main page.
That's all.
I am having a hard time finding the right code in the Codex, any help is appreciated.
I would like to display
- the most recent post
- AND the number of comments for that particular post
- on my main page.
That's all.
I am having a hard time finding the right code in the Codex, any help is appreciated.
Try:
<?php
$args=array(
'showposts'=>1,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
echo 'comment count is: ' . $post->comment_count;
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Review:
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
MichaelH, I stand in awe of your mad PHP-Skills. I can't thank you enough, it works like a charm.
You must log in to post.