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'm trying to build single-page theme. I want user to navigate thru menu with anchors (for example <a href="#About">About</a>). I've extended Walker for wp_list_pages so it outputs anchors instead of permalinks. How to bite it now? I thought I will use query_posts for 'post_type' => 'page' and just style those pages but is there more flexible way of doing this? Also this query displays all pages (all I want is just depth = 1) and I don't know how to order them same way as wp_list_pages does.

Maybe there is some text to read about this kind of pages on the internet?

share|improve this question
Static pages really don't lend themselves well to the infinite scroll/lazy load implementation. That technique works well for blog posts, because they are chronological, and all relate to one another on the basis of chronology. Static pages, on the other hand, are entirely stand-alone, have no chronology, and have no other means of correlation one to another. – Chip Bennett Apr 23 '12 at 17:00
@ChipBennett I don't like this kind of pages neither but that's not my idea and I simply have to do it. – smogg Apr 24 '12 at 9:39
up vote 1 down vote accepted

I've done a few templates that essentially are on one page. I used this code as the starting block for all of them:

    $my_wp_query = new WP_Query();
    $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','posts_per_page' => -1));
    foreach ($all_wp_pages as $value){
        $post = get_page($value);
        $slug = $post->post_name;
        $title = $post->post_title;
        $content = apply_filters('the_content', $post->post_content);

It basically gets every page, you can then use the variables to build the rendered markup.

Then a small change to meet you're depth requirement I would use:

$all_wp_pages = $my_wp_query->query(array('post_type' => 'page','depth' => 1, 'posts_per_page' => -1));

And finally 'posts_per_page' => -1 gets everypage, not limited to the number set in 'Admin > Settings > Reading'

Hope this helps.

share|improve this answer
Thanks Alex. I found out that depth doesn't work here. I've used 'post_parent' => 0 instead and it works fine. The last but not least problem is ordering. How to order pages same way they are ordered by wp_list_pages? – smogg Apr 24 '12 at 9:37
ahh i did do this too... let me dig it out. – Alex Thomas Apr 24 '12 at 9:40
try 'order'=>'ASC' – Alex Thomas Apr 24 '12 at 10:23
Tried already that and orderby and I still don't understand logic here. – smogg Apr 24 '12 at 10:48
I've sorted wp_list_pages using sort_column => menu_order and now I have what I need. Thanks – smogg Apr 24 '12 at 10:54

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.