Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to create an archive page that grabs every post submitted. At the moment, I have this, which doesn't work:


   $args = array ();
   $query = new WP_Query( $args );

if ( $query->have_posts() ) {
  while ( $query->have_posts() ) {

        <div class="post">

<?php first_item() ?>

} else {
  // no posts found

// Restore original Post Data
wp_reset_postdata(); ?>

However, if I change the array to:

   $args = array (
  'tag'                 => 'films',

It starts receiving all posts tagged as films.

How come this is only working with tagged posts, and not for every post?

I do have a loop on the front page and on custom page, so could they be conflicting?

share|improve this question
Your code is not complete, I guess. Where do you close What does first_item() do exactly? – tfrommen Dec 20 '13 at 10:48

1 Answer 1

You've given WP_Query and empty argument set, effectively asking it to get "nothing". Try:

$args = array ();
$query = new WP_Query( $args );

As soon as you give it something to latch onto, like your tag argument, the query works. To get all of your posts pass a post_type argument.

$args = array ('post_type'=>'post');
$query = new wp_query( $args );

Or to get all post types...

$args = array ('post_type'=>'any');
$query = new wp_query( $args );

Or to only get particular post types...

$args = array ('post_type'=> array('post','book'));
$query = new wp_query( $args );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.