(Moderator’s note: The original title was “Is there a way to get post comments by post ID on a custom loop using WP-Query()?”)

Hi! I’m running a custom loop using WP_Query, that only displays one post from a specific category on the home.php page, like so:

<?php $pr_q = "cat=11&posts_per_page=1"; $pregunta_q = new WP_Query($pr_q); ?>
<?php while ($pregunta_q->have_posts()) : $pregunta_q->the_post(); ?>
    <!-- post stuff here -->
<?php endwhile; ?>

Is there any way to have it show comments for that specific post? I tried including the comments template inside the loop and nothing. Is there a function that loads the comments for a specific post that I can use inside home.php or anywhere else?

4 s
4

To be able to use the comments template in your loops, add

global $withcomments; $withcomments = true;

Leave a Reply

Your email address will not be published. Required fields are marked *