Support » Fixing WordPress » Exclude all sub-pages from main header

  • Resolved josalmon


    Hi everyone,

    I want to develop an entire site using WP rather than just a blog but I’m having problems with sub-pages.

    On my main page, I’ve got the list of Pages but as I now have to create sub-pages, I don’t want them displayed on the main page – only on the parent Page relating to them

    For example, if I created two Pages, one about dogs and one about cats and then created a sub-page about dog food, I would only want the dog food Page to show up on the dogs Page.

    I can do the sub-Page list on individual pages no problems, but I’m having problemds excluding the sub pages from the main menu

    I’m currently using this code:

    <?php wp_list_pages('exclude=10&title_li='); ?>

    but I’m looking at creating 40 or so sub-pages scattered between 10 or so Pages.

    Is there a way of saying “exclude all sub pages” without having to go back to the original Page list and insert the sub-page ID each and every time I create one?

    To summarise – does anyone know some code that will only display Parent Pages?

    Cheers, Jo

Viewing 6 replies - 1 through 6 (of 6 total)
  • It’s fine, I figured it out!

    For anyone else who is interested, use this code to display the Parent Pages only:

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




    Which can be found here: Codex Entry for wp_list_pages


    I find the codex really hard to read – I went through it for an hour before I posted and nearly an hour after. But that’s why I posted again so you wouldn’t have to respond.




    The post was more for others comming along afterwards who may find it useful.

    PS: I find the Codex quite convoluted myself.

    I tried to do this but it doesn’t work for me.
    this is the code in my sidebar.php:

    <!– <?php wp_list_pages(‘depth=1&title_li=<h2>’ . __(‘Pages’) . ‘</h2>’ ); ?> –>

    did I do something wrong???

    I changed it to:
    <!– <?php wp_list_pages(‘depth=1’ . __(‘Pages’) . ‘</h2>’ ); ?> –>
    but it still doesn’t work. I read the codex about that but I can’t find whats wrong!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Exclude all sub-pages from main header’ is closed to new replies.