Hide a page or post from navigation in WordPress

Have you ever wanted to create a page in WordPress, but didn’t want it to show up on the menu?  Well, a client recently wanted me to create a “thank you” page on her WP site. After trying to figure it out on my own, I did some searching on Google and found the perfect tip to handle this.

You’ll have to be confident in editing the header.php page on your WP site.

Go to your WP admin panel then to Design > Theme Editor > then click on header.php in the Theme Files on the right.

Find the code below, which should be approximately 3/4 the way down the page.

<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=&exclude= 30,47,68,102,113'); ?>

Add the page ID's that you want to exclude here: exclude=15,47,68,102,113'); ?>

You can find the page or post ID’s by going to the WP admin panel, then go to Manage page or post.  Mouse over the page or post titles while looking at the status bar at the bottom of your screen. The ID number is the number at the very end of the link that shows. You can view the screenshot below:

WordPress Tip - Hiding Pages or Posts From Navigation
WordPress Tip - Hiding Pages or Posts From Navigation

There is much more that you can do with this, such as hiding posts in the sidebar navigation, but I’m not going to get into that here. You can see more on this where I initially found the tip that got me out of a bind on the very helpful site http://jarretcade.net. Jared has some great tips.

You can also contact me here if you would like some help on your WordPress site.

Be Sociable, Share!

24 thoughts on “Hide a page or post from navigation in WordPress

  1. Thanks. This really is an awkward way of hiding pages from the navigation. In any other CMS there'd be a simple option in the backend. You'd think WordPress would be able to do better.

  2. Thanks for good tip. Another way is to use css in the name of the page, for example you create a new page, make the title like : < span style=”display:none;”>your title page</span> ^^

  3. There’s a plugin called My Page Order that makes it very simple to exclude pages from a menu.

    In fact, my website uses the My Page Order widget repeatedly to provide multiple menus with specific pages on a certain topic.

    I also like the My Category Order plugin, for sites that will have posts and categories. Both are highly recommended.

    For new users who aren’t sure whether to set up their blog using posts or pages, this article might help shed some light on things:


    I do appreciate your posting the code fix. But some of us are a little paranoid about fiddling with code if we can possibly avoid it.

  4. Thanks Joanna, that looks like a good plugin and solution. I’m no longer using the hard coding to accomplish this either. I’m using the Exclude Pages from Navigation plugin, which just adds a checkbox to show whether to add to navigation or not. I’ll have to take a closer look at My Page Order. Thanks for the tip, and for stopping by!

  5. Adwords is really good in driving traffic to your website. however, they are very strict right now and they would not easily approve websites that they thought have low quality content. .`

  6. Daniel…yes, a lot of the newer themes have come out since the original post that have this feature. I use the Thesis theme a lot, and it has the ability to exclude pages from the navigation. Thanks for stopping by…I love Lafayette!

  7. Wow, neat article. I’m happy that I was able to drop by on your site. A client of mine wanted a web design with some hidden pages. Your article and comments here really added to my knowledge esp in website design using word press. Thanks.

  8. This was really helpful. I was trying to figure how to remove my home page navigation link and this did the trick. I appreciate the information and recommend it to anyone.

  9. Thanks Paul. This is a pretty old post, so all of the themes I use now already have this feature…especially with the new WP custom menu. But it does work well on the older themes.

Leave a Reply

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