loop within a page allowing for comments
-
Hi – I’d appreciate a hand with this as I’ve been trying for hours!
I have a page about oranges. It has a bit of text that can be updated using the CMS.
On that page I want to pull in posts with “oranges” set as their category. I want to allow people to comment on the page at the bottom of it.
So I have
<?php while (have_posts()) : the_post(); ?> This shows text from cms <?php endwhile; ?> <?php query_posts(category_name=oranges'); ?> list all posts with orange category <?php endwhile; ?> comments_template();
This works except if the last post has comments disabled it passes that info from the first loop to the 2nd so disables comments for the whole page.
Reading the page on the loop https://codex.www.ads-software.com/The_Loop I understand that I can’t query $wp_query twicw. So on the 2nd one I used:
<?php $my_query = new WP_Query category_name=oranges'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> list all posts with orange category <?php endwhile; ?>
But this had the same problem! I also tried <?php wp_reset_query(); ?> after the second loop and before the comments but still no joy! If anyone can out me on the right track that would be great!!!!
appreciated
Matt
- The topic ‘loop within a page allowing for comments’ is closed to new replies.