Grow your CSS skills. Land your dream job.

How can I display all of my pages on a single page in WordPress?

  • # June 7, 2011 at 11:52 pm

    I’m experimenting with a one page design. I want each page in the back end to display as a different section. Is there a way to loop through my pages and display them all?

    # June 8, 2011 at 1:20 am

    Oooo I like answering the easy WP questions!

    < ?php query_posts('post_type=page'); ?>
    < ?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    < ?php the_title(); ?>

    < ?php the_content(); ?>
    < ?php endwhile; endif; ?>
    # June 8, 2011 at 1:15 pm

    I”m not in a place I can test, but I trust you. Thanks a lot Doc.

    # June 9, 2011 at 12:26 am

    When they display, they art sorted by their “Order” number, which is fine, But it’s putting the lowest at the bottom. How can I reverse the order they’re displayed?

    # June 9, 2011 at 3:04 am

    And also, how could I exclude sub-pages?

    # June 9, 2011 at 11:24 am
    < ?php query_posts('post_type=page&order=ASC'); ?>

    As far as I know, you can’t exclude subpages when doing a query unless you manually specify the pages.

    You can do that with the ‘depth’ parameter in wp_list_pages though.

    # June 9, 2011 at 11:59 am

    Thanks a lot for the help Doc :)

    # June 13, 2011 at 3:07 am

    How do I use the depth parameter? I can’t figure it out :(

    # June 13, 2011 at 10:23 am

    You can only use the depth parameter with wp_list_pages. So something like this:

    < ?php wp_list_pages('depth=1'); ?>

    This cannot be used with the regular Loop.

    # June 13, 2011 at 12:06 pm

    Ah, I see.

    So if I wanted to add mark up to the generated pages, but I’m not using a loop, how would I do that?

    # June 13, 2011 at 12:11 pm

    The wp_list_pages function only lists the titles. If you want to have the content show you’ll have to use the loop.

    If you know the IDs of the pages then you can just run a loop of those specific pages. The only thing you can do, really.

    # June 13, 2011 at 1:42 pm

    Shucks.

    Thanks for all the help Doc

    # June 15, 2011 at 5:15 pm

    Okay, here is an update. I found a working solution and shows only the top level pages. that I can even add mark up to. But another issue came up. Here is the code:

    < ?php
    $pages = get_pages('parent=0');
    foreach ($pages as $pagg) {
    $option .= $pagg->
    ;
    $option .= $pagg->post_title;
    $option .= $pagg->post_content;
    $option .= $pagg->
    ;
    echo $option;
    }
    ?>

    The problem is the content from the pages has been stripped of all it’s html. There’s no formatting in it. Any way I can keep it?

    # January 8, 2013 at 12:29 am

    I have a similar question, I want to add all pages (where the user has checked the option while publishing) to add the page to the single page?

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".