Exclude Pages In WordPress Navigation Menu

Posted on

  • email
  • twitter
  • facebook
  • share this

share this

advertisement

Wordpress is clearly the go-to open-source blogging software (and some would say content management system) for the Web entrepreneur and affiliate marketers. Despite its active support community and broad extensibility, new installations often require some tweaking.

One of the main issues many have is what to do when they have too many pages in their navigation menu. Let's look at two ways to exclude pages and customize a WordPress navigation menu.

The Coding Way
The first way to exclude pages is to do hack the source code a little. If you are comforable making some adjustments to PHP files, go to the theme editor under "Presentation" and select header.php. From here, look for the wp_list_pagse() tag - it often looks like this <?php wp_list_pages('title_li=&depth=-1);?>. To exclude pages, simply add the (=&exclude= 1,2,3) (without the paranthesis) wherein the numbers represent the page IDs you want to hide from the navigation menu. For example, the whole string would look like the following:

  • <?php wp_list_pages(’title_li=&depth=-1=&exclude= 1,2,3‘); ?>

The one problem with this method is that you need to exclude pages each time you create them. Is there a better way? Why, yes, of course!

The Plugin Way
As has been said over and over before, the real beauty of WordPress is the extensibility. Thousands of available plugins give you the ability to add some unique functionality without having to know how to code. If you don't wan't to have to exclude pages manually, there is a way - the plugin way.

The Exclude Pages WordPress Plugin by Simon Wheatley enables bloggers to hide pages in a WordPress blog. This plugin adds a checkbox, “include this page in menus”, which is checked by default. If you uncheck it, the page will not appear in any listings of pages (which includes, and is usually limited to, your page navigation menus). Pages which are children of excluded pages also do not show up in menu listings. (An alert in the editing screen, underneath the "include" checkbox allows you to track down which ancestor page is affecting child pages in this way.)

Do you know of other page exclusion methods or plugins?
Share them with other readers of Website Magazine by commenting below.

 

Custom WordPress Design Themes at 99designs.com. Get the most designs for your buck when you start a design project!


Login To Comment

forget your login information?

Become a Member

Not already a part of our community? Sign up to participate in the discussion. It’s free and quick.

Sign Up

3 comments

Nick 01-07-2009 12:29 PM

Other plugins allow you to specify what you want in your nav menu(s) instead of it being automatic. For WP as CMS users, that's a better way - since you can create exactly what parent, page, category, etc. you want to have as a nav item.

Some plugins allow you to have multiple navs, anywhere you want to place the little line of code -- all administered and controlled by a page in your admin. As always, some plugins are better than others for this... but experiment and find the one that suits your needs.

Jack Kennard 01-25-2009 5:34 AM

I never thought of this before, but after reading this last week I must have come up with 3 or 4 postings this would be great for.

PoliceReady 04-04-2009 9:09 PM

The mentioned plugin is too limiting as it also prevents you using built-in wordpress functions such as get_posts on the hidden menu items.

Add to the discussion!

advertisement

999 E Touhy Ave
Des Plaines, IL 60018

Toll Free: 1.800.817.1518
International: 1.773.628.2779
Fax: 1.773.272.0920
Email: info@websitemagazine.com

Facebook


Twitter