How to Display Selected WordPress Pages 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

Disclosure: Some of the links in this article are affiliate links and we may earn a small commission if you make a purchase, which helps us to keep delivering quality content to you. Here is our disclosure policy.

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Captcha verification failed!
CAPTCHA user score failed. Please contact us!

spot_img

Related Articles

Why Custom Software Development Drives Business Success

Companies desire software solutions that are specifically designed to their specific processes and objectives in today's high-speed virtual world.  While...
Read More
We started WPArena back in 2008 and we had one main goal: teaching people how to be successful with WordPress....
Imagine walking into a library where books are scattered everywhere with no rhyme or reason. Frustrating, right? The same goes...