Choose WordPress Pages Displayed In Navigation Bar
If your blog has a navigation bar in or near the header and you create a lot of pages on your WordPress blog chances are it is getting somewhat cluttered. You can control what pages are displayed by including the ones you want or excluding a certain few. Here is a short WordPress guide to help you clean things up.
Warning before editing any theme files make a backup so you can fix any mistakes!
The first thing to decide is if you are going to include certain pages or exclude certain pages. Each page has an ID number associated with it. To find the page’s ID numbers in the dashboard click Manage, Pages and look for the ID number of the page. Next open your header.php file and look for this code:
<?php wp_list_pages(’depth=1&title_li=’); ?>
That bit of code is going to display all the pages you create. To exclude certain pages use the below code in its place and add the page ID numbers comma separated. The example below is excluding page ID 6 and 4.
<?php wp_list_pages(’title_li=&depth=1&exclude=6,4′); ?>
To include only certain pages you can try this next bit of code:
<?php wp_list_pages(’title_li=&depth=1&include=6,4′); ?>
There are many more parameters to list pages, learn more about WordPress page navigation here: WP List Pages
You can also ‘hard code’ any URL in the WordPress navigation bar as this previous post explains: Specify WordPress Navigation Page Links
Customize WordPress WordPress WordPress Guide WordPress guidesIf you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Tagged with Customize WordPress, WordPress, WordPress Guide, WordPress guides
Related Posts
11 Responses to “Choose WordPress Pages Displayed In Navigation Bar”
Discussion Area - Leave a Comment
If you have a question about your blog please leave a link to it. Please don't ask questions like "Why don't my blog work right?" and expect an answer.Two links or less are welcome, any more and your comment will be spammed! Nofollow has been disabled, all comments are moderated and will not appear until approved. Please submit only once.
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Or just copy the example below and change your details.
Example - <a href="http://www.YourSite.com">Title Of Site</a>










Good tip Jeff! I have five pages on my nav. Do you think that would be considered cluttered? My thought is to get the “pages” up there above the header, out of the sidebar.
Alex
Alex you will know when they are cluttered when the pages start to wrap around and you have two rows!
No yours looks fine.
Great guide. Thanks for solving my problem.
Hi there,
I was looking how to do this and tried to - I changed the sidebar php via the theme editor, but nothing changed on my site. Does it have anything to do with the theme using widgets?
Eva This guide is for the navigation in the Header not the sidebar.
If you tried that in the sidebar and you are using widgets, then (usually depending on the theme) the widgets will override the code for pages in the sidebar files. As soon as you drag a widget into the sidebar it will stop showing the default or hard coded sidebar items.
To exclude pages in the sidebar go to the Pages sidebar widget (Presentation, Widgets) click the pages widget to open it and choose what page ID to exclude.
Thanks for the quick reply, Jeff. I haven’t done much with widgets, and the only thing I seem to be able to change is the title of the “Pages” widget. It doesn’t give me any option to enter/exclude anything else.
Eva you are running WordPress 2.0.4, that is probably why. I don’t know exactly when/what version that option was available but perhaps an upgrade is in order?
I prefer to keep the advertising on my blog to a minimum. I just use a few banners for related products and a subscription form for my list. I prefer not to use Adsense or any other similar services. A cluttered blog can overwhelm visitors and stop them from reading.
Useful article, thank you + it helped out on my site!
[…] to large and cluttering up your sites top navigation or Pages sidebar widget check out this post: Choose WordPress Pages Displayed In Navigation Bar WordPress Guide Share This Gregarious FeedFlareIf you’re new here, you may want to […]
Thanks Jeff, that was what I was looking for - the explanation on WP site - http://codex.wordpress.org/wp_list_pages - did not have what you so quickly provided. Thanks.