Hi guys,
I'm trying to spit out some recent post comments on my homepage. I can use most of the Comment template tags (http://codex.wordpress.org/Template_Tags) fine, but having real issues with wp_list_comments() for some reason???
I have tried it with parameters, but still no luck.
<?php $my_query = new WP_Query('cat=3&posts_per_page=1&order=dsc'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<? wp_list_comments(); ?>
<?php endwhile; ?>
What am I doing wrong?
PS Outside the loop*
Thanks in advance,
That's because the function relies on either...
a) You feeding it an array of comment objects
or
b) falling back to $wp_query->comments ($wp_query being the main query)
See.
http://core.trac.wordpress.org/browser/trunk/wp-includes/comment-template.php
Around line 1360.. see the comments above the function.
Hi mate,
Thanks for your response. I can't get anything working using wp_list_comments().
At present I'm using, which works, but not ideal:
function featureBox() { ?>
<?php $my_query = new WP_Query('cat=3&posts_per_page=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
$id = (int)$my_query->post->ID;
$q = mysql_query("select * from wp_comments where comment_post_ID='{$id}' limit 1");
$i = 0;
while($info = mysql_fetch_object($q)) {
if($i>2) break;
print $info->comment_content;
$i++;
}
?>
<?php endwhile; ?>
<?php }
add_action('thesis_hook_feature_box', 'featureBox');
Any further hints?
Thanks,