WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't consider myself to be a newb, I've had a loop of all the pages work before, but right now one of my custom loops on my page template (which is used as the index page of the site), will not show a list of 'pages'.

<?php get_header(); ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> // first I want to call the information for the page itself -- i've tried removing this and it has no effect.
<div class="about"><?php the_content(); ?></div>

<?php endwhile; 

// end frontpage while ?>

    <div id="featured" >  
        <ul class="ui-tabs-nav">  
            <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"><span>About the film festival</span></a></li>  

        $get_pages =    ( //the loop to get all the pages on the site

                    'post_type' => 'page',
                    'posts_per_page' => -1,

                query_posts( $get_pages );

        if ( have_posts() ) while ( have_posts() ) : the_post(); 

// this here is what I want to happen for each page, but it shows up for anything aside from page

 <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><span><?php the_title() ?></span></a></li>  

    <?php endwhile; //end pages while
                wp_reset_postdata();     ?>

Am I missing something crucial? Is there a stupid mistake? I am clueless at the moment. Tanks for anything that might help here.

share|improve this question
up vote 1 down vote accepted

This is not the place to use query_posts. query_posts should only be used if you need to change the main loop. There is also no need to reset the query and your missing endif on both loops.

I would use get_pages instead of running a new WP_Query.

$pages = get_pages();
foreach ( $pages as $page ) { ?>

<li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><span><?php echo $page->post_title; ?></span></a></li> 

    <?php }
share|improve this answer
grand. thanks for that! i didn't realise there was a specific difference between the two methods of querying there. Anywho. This worked like a charm and I've tidied up all my other queries accordingly. Tanks. – josh Apr 18 '12 at 13:37

Nothing is jumping out at me as being outright wrong (though you have some spotty use of brackets in a few places), but it's not good practice to use query_posts() like this (twice in a page, with wp_reset_query()), and it's possible that some sort of related global conflict is causing your issue. Try using WP_Query instead:

$page_args = array(
    'post_type' => 'page',
    'posts_per_page' => -1,
$page_query = new WP_Query( $page_args );

if ( $page_query->have_posts() ) :
    while ( $page_query->have_posts() ) :
         <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><span><?php the_title() ?></span></a></li>
share|improve this answer
I tried switching here and got the following error: 'Notice: Undefined offset: 1 in /Users/joshuef/Development/onfilm/wp-includes/query.php on line 2772 ' – josh Apr 18 '12 at 13:25

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.