To Hide or unlink pages from the main menu in WordPress

To hide a page or post from the navigation menu in WordPress do this usually in your theme’s sidebar.php or header.php if you are using pages on your menu. Note: most people are not using pages, posts are default for the navigation menu:

<ul>
<li><a href="<?php bloginfo('url'); ?>">Home</a></li>
<?php wp_list_pages('title_li=&depth=1&exclude=8'); ?>
</ul>

Really, the key part is "&exclude=8", find the page you want to hide or unlink from the menu by clicking on it and reading the location in the URL bar up top in your browser, or inspect it in WordPress on the backend.

The number or page name (usually the "slug") is the important part. If you want to exclude more than one, use a comma.

ex: wp_list_pages('title_li=&depth=1&exclude=6,8')

If you cannot find the page_id, here’s a tip:

To find the page id instead of the slug or page name on newer WordPress installs, go to the backend, click on the pages (or posts) edit menu, hover you mouse over the page name and look at your status bar in the bottom of your browser window, it will end in a number. That number is your page_id. This page_id is a way to load that page. You can substitute it for the slug to find any page on your blog.

ie: www.myblog.com/new-page will also load with www.myblog.com/?page_id=3

from: http://codex.wordpress.org/Template_Tags/wp_list_pages

Leave a comment