i need to show only last 5 comment for guestbook box on homepage (index.php)
i this code good for show comment from guestbook page, but show all comment, if i need to show only 5 comment how to limit it.
thanks you
<?php query_posts('pagename=guestbook'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
I've not tested this but it should work:
<?php query_posts('pagename=guestbook'); ?>
<?php
$count = 0;
$limit = 5;
while (have_posts() && $count++ < $limit) : the_post();
?>
<?php comments_template(); ?>
<?php endwhile; ?>
Change $limit if you want more or less comments
thank you rob.s
now i found this code and Work! :)
<?php get_comments('array_args'); ?>
http://codex.wordpress.org/Function_Reference/get_comments
and limit comment by number
<?php get_comments('post_id=172&number=5'); ?>
No worries, that solution is a lot neater than mine :)