How to Display Selected WordPress Pages in Navigation Bar

Customize WordPress Header 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

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like