Excluding Pages In Wordpress Navigation Menu
Posted on 21st September 2008 by BrandiHave you ever wanted to exclude certain pages from your headbar navigation area? There is a way.
Sometimes you might want to have a page, but not have it visible in your main navigation area up top. I have found, often times, that I want to have a static (non-changing, informational) home page (instead of blog posts), but it will add that page in the navigation area, along with a “home” link that’s most often already there. I have also found that the top navigation area can become quite cluttered, ultimately leading to the navigation area looking messed up or not good with the theme. Sometimes you just don’t want it up there and would like to link to it elsewhere, say your sidebar for instance. This can all be done with slight alteration to “the code”.
First things first. You will need to know the “Page ID”. I always find this by way of “Manage Pages” via the WP Dashboard (admin area). When you’re looking at your list of pages, you can simply HOVER OVER the title of your page. In the bottom left hand corner of your Internet Browser (IE, Firefox, etc.) you will see a link similar to this:
http://areyouwordpressed.com/wp-admin/page.php?action=edit&post=2
The “areyouwordpressed.com” will be substituted with your blog url. The 2 is your Page ID. I would, personally, write out a list the page title and the Page ID to have quick access to it while you’re altering the code, which we’re about to do here in a second.
Next, you will want to go back to your WP Dashboard, go to Design > Theme Editor, and then look for a page listed on the right called header.php. (Once you get there, I would right click, select all, then copy. Open a blank notepad document and paste it there. That way if anything happens to get screwed up, you have a good copy of what you started with to begin with, before you made any changes, or accidentally did something wrong.)
Once there, you will want to look for something that looks like this:
<?php wp_list_pages();?>
This is a snippet of php code that tells Wordpress to list all of your pages between the parenthesis. In order to exclude certain pages, you will add the following with no spaces:
'exclude=4,19'
Your new code will look like the following:
<?php wp_list_pages('exclude=4,19');?>
***The numbers 4 and 19 are dummy Page IDs. You will replace the 4 and 19 with YOUR Page IDs. If you have more than two, you will just continue the trend, Page ID # COMMA Page ID # COMMA Page ID # COMMA.
Make sure to click “Update File” at the bottom left of the page when you’re done, and VOILA! You have successfully excluded whatever page(s) you want from the navigation bar of your site! If for some reason you goofed or something doesn’t look right, refer back to that notepad document you copied all the original code into. Simply clear out everything in the theme editor on that page, then copy and paste the original code back in there and try again!
Good luck!
Popularity: 33% [?]


