How do I remove certain pages from my WordPress menu?

When a blog theme automatically puts new pages in a tab at the top, how do you make a page but put the link in the sidebar?


I got this question from from Elizabeth from Getting My Blog On over an MSN chat session. She’s been learning more and more everyday about WordPress, but you know how it is, the more you learn, the more there IS to learn, and sometimes committing it all to memory can be quite hard.

I gave a quite look in the WordPress codex as I seemed to remember there was a parameter on the function that lists pages, and indeed there was. You see,the function that lists all the pages is as follows:

<?php wp_list_pages('arguments'); ?>

This has a number of parameters, shown here with their default values:
$defaults = array(
'depth' => 0,
'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0,
'exclude' => '',
'title_li' => __('Pages'),
'echo' => 1,
'authors' => '',
'sort_column' => 'menu_order, post_title');

You can change any of those details by specifying the value that you want. In this case, let’s say the page to exclude had an ID of 5 (you can see the ID in the URL when you’re editing the page), all she had to do was make sure that the line in her header containing wp_list_pages had a parameter with exclude in it, a bit like this:

<?php wp_list_pages('exclude=5' ); ?>

It is possible for a WordPress theme author to give you a configuration page to do this, but most of them don’t so it’s good to know how to do it.

2 thoughts on “How do I remove certain pages from my WordPress menu?

  1. Great post, I dont see allot of wordpress coding posts and have really started to play around myself with different plugins. I can see where this would be helpful for site appearance.

  2. I’ve found it useful to edit the code to ADD pages to make a blog more of a static site mixed with a blog without having to build sites – great when the ‘friend you are helping’ has no budget to have you spend the time to build a real site.

Leave a Reply

Your email address will not be published. Required fields are marked *