Tutorials

How to Display Selected WordPress Pages in Navigation Bar

Pinterest LinkedIn Tumblr

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

Editorial Staff

Editorial Staff at WPArena is a team of WordPress experts led by Jazib Zaman. Page maintained by Jazib Zaman.

Write A Comment

Pin It