One of the biggest things a lot of WordPress users look for in a new theme is easy navigation. You can always add Page and Category widgets to your sidebar, but having a well organized navigation bar (or two) can make a huge difference for your blog’s visitors.
Not all themes come with navigation bars built in, and even when they do, you might need to modify them a bit. While a navbar may seem like a simple thing at first, there are actually a TON of different things that you can do to make sure your site is as user-friendly as possible.
The first thing you need to decide is what you want your navigation bar to display. Generally, navigation bars come in two flavors: Categories and Pages. Some blogs (like this one) will use two navbars, one for each option, or even combine the two into one line. The only risk with this last option is that you can quickly find yourself running out of space if you add too many new pages or categories to your site.
How To Switch Your Navigation Bar From Pages To Categories (or vice versa)
If the navigation on your current theme isn’t showing what you want, don’t worry! Switching from Category to Page based navigation is easy!
The first thing we need to do is open up your theme’s
header.php file, either by using the theme editor under WordPress’ “Apearance” tab, or by downloading the file with your favorite FTP client.
Your navigation bar is controlled by a template tag, either
header.php for the tag that applies to you, and if you need to, you can replace it with the one you’d rather be using. The tag will include a number of parameters, grouped in parenthesis, and we’re going to be adding to these in a moment.
Locating the ID of a Page or Category
Now that you’ve found the template tag that’s controlling your navigation, it’s time to add a parameter to hide the pages you don’t want to see. In order to do this, you’ll need each of those pages’ ID numbers.
In addition to the names you give them, WordPress assigns every category and page a unique ID number. To find that number, pull up the page (or category) editing screen of your dashboard. As you hover over each entry, a row of links will appear, one of them being “edit.”
Hover over that “edit” link and look at the bottom bar of your browser. The destination URL of the link is displayed, and ends with the page/category ID. For those of you on a Mac, you’ll just want to click the “Edit” link and look at the URL it takes you to.
At the end of the “Edit” URL, pages will say “
post=” and categories will say “
cat_id=” followed by a number. That number is the ID you need, and we’ll discuss where to use it a little later on.
How To Exclude Specific Pages or Categories
The most common thing that people want to do is hide a page on on their navigation bar. This could be a “Thank You” page for new subscribers, or an intermediate page for visitors going through a certain process. An example of this would be on this site, when a new client signs up for a WordPress installation, there are a few different pages that guide them through the process of scheduling an appointment, acquiring hosting, etc. These pages are all necessary, but aren’t something I want all over the top of every page.
Hiding a page from your navigation bar is easily accomplished by using one of the several parameters we’ll be going over. This is the (you guessed it!) “
To exclude the page you want, enter the parameter, followed by the ID of the page/category in question:
In this example, I’ve used
list_pages, but it works the same way with the categories tag. As you can see I’ve included multiple ID’s, separated by commas. You can just as easily use only a single ID with no comma if you only have one item to hide.
When entering your parameters, don’t forget to wrap them in parenthesis, and enclose them in quotation marks as I’ve done above.
Limiting Navigation To Specific Pages
If you have a situation where you only want to display certain pages or categories on you navigation bar, you can certainly use the
exclude parameter to hide all of your other pages, but depending on the size of your site, gathering all of those IDs can be a bit tedious. In addition, every time you create a new page or category, you’ll need to go back into
header.php to add the new ID.
The solution is to switch to the
Once again, this parameter works for both the page and category tags. Using
include will display all the pages listed, so if you add new pages in the future, they won’t show up unless want them to (in which case, you’ll add the new ID to the template tag in
Note: The order that you list the ID’s in does not impact the order the pages will display in. To rearrange the page order, use the “Order” field, under “Attributes” in the right hand column of the the “Edit Page” screen.
Dealing With Multiple Parameters
As I mentioned above, the template tag you are modifying probably already has some parameters already defined. The most common parameter on a navigation bar is probably ‘
title_li=.’ This parameter is used to define the title that appears at the beginning of the list.
Generally, a navigation bar doesn’t need a title, so the parameter is left blank, with nothing after the “=” sign. This is the equivalent of saying “don’t display any title.” Here’s an example of that parameter in action:
So, how do you combine an existing parameter(s) with your new
exclude? Like this!
Nice and easy. 🙂 Just place an ampersand (&) at the end of the existing parameter(s), then add your new one. Note that the entire group of parameters (called a ‘string’) is included within the quotation marks. Make sure those are in place, and that all of your parameters are inside them, and you’ll be good to go!
And that’s it! That’s really all there is to selecting what pages you want to include or exclude from your navigation bar.
Have fun, and if you have any questions, drop them in the comments!