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

Tuesday, December 11, 2007 1:17
Posted in category Wordpress

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

You can leave a response, or trackback from your own site.
Tags: ,

10 Responses to “How to hide or exclude a page from the Wordpress main menu”

  1. Jim says:

    October 1st, 2008 at 3:45 pm

    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 says:

    October 1st, 2008 at 3:52 pm

    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 says:

    September 10th, 2009 at 3:37 pm

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

  4. angelina jolie says:

    September 10th, 2009 at 5:20 pm

    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 says:

    October 22nd, 2009 at 8:02 am

    Yes ! Really helpful .. Thanks for the post

  6. gcreator says:

    March 13th, 2010 at 10:51 am

    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 says:

    March 13th, 2010 at 11:16 am

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

  8. gcreator says:

    March 13th, 2010 at 11:24 am

    dear Sid , i mean how to make a page unclickable

    e.g. make unclickable a parent page

  9. Beeb Ashcroft says:

    April 21st, 2010 at 7:30 pm

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

  10. NoMad says:

    May 13th, 2010 at 10:45 pm

    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/

Leave a Reply

Note: This post is over 2 years old. You may want to check later in this blog to see if there is new information relevant to your comment.