Knowing how to hide wordpress pages from the header horizontal navigation menu is useful especially when you:
1. have a number of pages and do not want to clutter the navigation menu with your page titles.
2. want to create a special page for the purpose of linking from your posts or other pages.
Below is a way to hide unwanted page links from your navigation menu:
1. Go to your Wordpress Editor (Appearance section) and open the header.php file and look for the following codes:
<?php $children = wp_list_pages(’sort_column=menu_order&depth=1&title_li=’);?>
2. Add the following codes (in green) and page IDs (in blue) that you want to exclude from the navigation menu as follows:
<?php $children = wp_list_pages(’sort_column=menu_order&depth=1&title_li=&exclude=1,2,3‘);?>
Header.php codes in different themes may look different as shown in the example below. In this example, add the codes (in green) and page IDs (in blue) in the manner shown below to exclude the page links:
<div id=”navigation”>
<ul class=”nav”>
<li id=”<?php if (is_home()) { ?>home<?php } else { ?>page_item<?php } ?>”><a href=”<?php bloginfo(’url’); ?>” title=”Home”>Home</a></li><?php wp_list_pages(’title_li=&depth=1&title_li=&exclude=1,2,3‘); ?>
</ul>
</div>
Note: The page IDs 1, 2,3 is for illustration only. Click here to learn how to get the actual post or page IDs.
With this knowledge, you will have a much wider selection of Wordpress themes that you can use as most of them have horizontal page menus.
If you like this post, please consider subscribing to this site’s RSS feed. You can also subscribe by email and any new posts will be sent directly to your inbox.
Leave a Reply
You must be logged in to post a comment.