Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Posts disappear when I use the wp_query

I have created a tag page template and when I use the standard Worpress loop the content displays correctly. But, I have to order the post and when I use the wp_query the content disappears and the tag page shows as empty. I have written the query correctly but can't understand why it is not working. Any ideas?

3 Answers

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

Did you use have_posts() function or the_post() with it?

I used the function like this:

<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Try adding your variable to have_posts in the if part of the function

like this

 <?php if (  $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

Hope this helps.

What do you have set up in your array for your var $args?