Looking to hide WordPress pages? If you’ve downloaded a WordPress theme that has been made available to the general public, it is likely that, by default, it has some code that automatically inserts your WordPress pages directly into your theme without any manual coding. This is a really great feature most of the time, but sometimes there are certain pages you’d like to not display in your menu or not display at all (search results page comes to mind).

Hide WordPress Pages

Here is how the menu code probably looks in your theme:

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

If you have a individual page you’ve created, but don’t want to display it in your blog’s menu, you simply need to add an exclude command and the page number (this can be found on Manage -> Pages) to your existing code. Here is how the same code would look if I was excluding page 55:

<?php wp_list_pages('depth=1&sort_column=menu_order&exclude=55&title_li=' . __('') . '' ); ?>

If you’d prefer to exclude more than one page, you can do so by simply adding a comma between each page number like so:

<?php wp_list_pages('depth=1&sort_column=menu_order&exclude=55,422&title_li=' . __('') . '' ); ?>

This code will exclude pages 55 and page 422 from your page menu.

Any other questions?  Feel free to post them below.

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Follow Kyle on Twitter @KyleEslick!

  1. Jacob says:

    I know there is no built in feature for this request, but I am determined to find a way to exclude a category from wp_list_pages.

    From all the research so far I know that you can use a var, like:

    wp_list_pages(‘exclude=’ . $whatever);

    But I am not sure how to load that var with a list of page ids from a category.

    So basically I am asking if there is a way to return a list of page ids in a category. Any ideas anyone?

    Thanks in advance!

  2. FreeBSD News says:

    Thanks for this – it’s exactly what i’ve been looking for. I want to hide some pages from the top menu on my blog (otherwise it will look too busy there) and show instead all pages on the side.

    BTW, your sitemap isn’t working.

  3. Big Fish says:

    Thanks for this tweak! I just got rid of the poll archive from my menu.

  4. Mark B says:

    Is there a similar way to limit a search to only a few categories? I need to two different searches in a site…one of them should only echo results from a specific category. I would appreciate any help!!!

  5. Kyle Eslick says:

    @ Mark – Good question. The only thing that comes to mind is to use the WordPress default search engine, then also add a Google Custom Search Engine (GCSE) with the specified categories only.

    Not 100% sure that would work, but might be worth looking into!

  6. Why not just save the page as a draft? It hides the page from the menu, but you can link directly to it…

    • Elaine says:


      I know you posted this a while back, but I was wondering if you were able to figure out how to do this? I tried making the post as draft and only using the link. As the owner of the site I can access the page through the link but obviously other people can’t. If you can help me, that would be great! Thanks!

  7. Nellie says:

    There is actually a wordpress plug-in for all of this to hide the page(s).


    Just in case one link doesn’t work the other should.

  8. lily says:

    thnx dude =) works perfectly by adding &exclude inside the parameter.

    • patricia says:

      Great post, but how do you find the page number ? my pages have names 🙁

      thank you

      • ale says:

        visit your dashboard pages, and instead of clicking on the actual page to “edit” hover over the word “edit” and you will see the number of your page in the bottom bar of your browser.

  9. Dani says:

    Thank you so much! This worked perfectly!

  10. Ailene says:

    Thanks! Very helpful.. :))

  11. Sally says:

    Exactly what I wanted!

    Thanks for sharing this, I have been going mad trying to figure it out, Sally 🙂

  12. Satish says:

    Hi there. I am using a WordPress template which doesnt have the function and I also installed a Exclude page plugin by Simon Wheatley and followed the instructions but the child pages still show up on header and I am not able to exclude those! Please help! Thanks


  13. Nope says:

    This didn’t work.. I couldn’t find the section to put this code in! and the plugin above did not work either.

  14. Nope says:

    Why do you just say “page number (this can be found on Manage -> Pages) to your existing code.” WHERE do you enter the code.. why don’t you just say this??

  15. I was racking my brains on exactly this same issue. How do I create a page that is not visible in the menu.

    The reason for that was I wanted to create a downloads page but capture the details of who was getting to the downloads page beforehand. And didn’t want the downloads page to be visible in the menu directly.

    Will give this a go today evening 🙂

    Thanks guys.


  16. halexblue says:

    Hi there,

    To be concise, I have several pages that I haven’t done working on. I have to hide them from visitor, but I need the visitor to know that the pages exist. What I want is to create those undone pages to be listed in the navigation menu, only without links. I’ve found out many ways to disable link to parent pages, but I didn’t manage to find how to disable individual links (not only parent links). The works well to prevent the page from being enlisted in the navigation. But what I desire here is to only disable the link and keep the title of the page enlisted.

    I hope my explanation is quite clear. My English is not good.

    Thank you in advance for the enlightement.

  17. Mark Crawford says:

    You legend!! This is one of the most simple but useful Plugins I have come across. I just wish I had found it several hours of wading through code ago. Nice one

  18. PBK says:

    This was exactly what I’ve been looking for. I’m not at all a programmer but knew there had to be a way to do this! I was using a theme that had single level tab links across the top but I wanted to choose which tabs would be on top. I found the “wp_list_pages” code mentioned above was located in the header.php file of my theme. It worked like a charm!
    Thank you again to people who are willing to take a few minutes and share what they know. You’ve saved me days and days of troubleshooting!
    Note: Before I made any changes I made a backup copy of the functioning code first!

  19. Kyathi says:

    Nice post

  20. kim holm says:

    This is a really usefull feature you have presented here, and I want to use it.

    I am not a programmer and dont know where to find the lines you are talking about, so I can meke the exclusion.

    Could you please show me?

    Best regards


  21. Alex says:

    Thanks, didn’t know it was so easy to hide a page.

  22. Blake says:


    You can also use the below plugin which adds a tick box when creating the page asking if you want the page to be visible.


  23. Rehmat says:

    I couldn’t find the piece of code, please the specify the file.

  24. Anil Kumar says:

    Thanks working great

Trackbacks/Pingbacks »

  1. 100+ Killer Wordpress Resources | Steffan Antonas’ Blog says:
  2. WordPress Resources – 48 Resources, Tips, Tricks & Themes | X Design Blog says:
  3. 23 articles and resources to improve your Wordpress life! | JortK.nl says:

Tweetbacks »