How to hide or exclude a page from the WordPress main menu

The main menu is populated by your theme, probably by the header.php file, with the function
<?php wp_list_pages('arguments'); ?>
So, if you want to exclude a specific page from being on the main menu I would suggest these two solutions:

  1. The simply oneIf your theme shows just the root pages and you don’t mind about the real position of the page…
    1. Create an empty root page and set its state to draft, in this way it will not appear in the main menu.
    2. Create the desired page under the just-created one and publish it.The page will be available from the slug
  2. The true oneIf you need the page to be root, or if your theme shows page childrends…
    1. Open header.php from your theme directory
    2. Modify the wp_list_pages function adding an exclude parameter, like the following exampleBefore:
      <?php wp_list_pages('title_li='); ?>
      After:
      <?php wp_list_pages('exclude=123,456&title_li='); ?>
      Where 123 and 456 are the ids of the pages you want to exclude from the list



11 Comments

  1. Jim wrote:

    Thanks a lot for the tips. It helps me a lot for Hiding my page in Home page. Added this Tips in my collection.

  2. Fedmich wrote:

    Doesn’t work anymore on new version of wp.

    but this patch worked for me, http://www.texto.de/texto/wp-25-wp_list_pages-exclude-bugfix/#comment-21715

  3. sandrar wrote:

    Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

  4. I love your site. :) Love design!!! I just came across your blog and wanted to say that I?ve really enjoyed browsing your blog posts. Sign: ndsam

  5. shine wrote:

    Yes ! Really helpful .. Thanks for the post

  6. gcreator wrote:

    great post!

    But i have a question : How to make a page at menu bar invisible but no hidden?

    thanks!-sorry for my bad english!

  7. Sid wrote:

    mcreator: what’s the difference between invisible and hidden?!?

  8. gcreator wrote:

    dear Sid , i mean how to make a page unclickable

    e.g. make unclickable a parent page

  9. Beeb Ashcroft wrote:

    This worked like a charm! Thanks so much for your post!

  10. NoMad wrote:

    It worked, thanks, but you have to know what is the page id… see link below for a helpful hint:
    http://www.techtrot.com/wordpress-page-id/

  11. That was a very helpful article.
    Just fixed an issue at my blog.
    Thank you!