How to Display Specific Pages/Links in WordPress Navigation Menu

If your WordPress blog has a navigation or top menu bar that shows all your WordPress pages and you create a lot of pages this can become quite cluttered. You can change this to specify the pages or links displayed from within your WordPress themes template files. This WordPress guide shows how to specify WordPress navigation page links.

First, your themes files will need to be writable in order to edit them from within the WordPress dashboard or you will need to edit the file and upload it with an FTP client. Another option is to edit the file in the hosting account file manager or make the theme’s files writable. From within the WordPress dashboard click Presentation or Appearance and then the Theme Editor. On the right side of the theme editor click, Header to open the header.php file. Depending on your theme you should see some code that looks like this:

    <div id="top-menu">
    <ul>
    <li><a <?php if (is_home()) echo('class="current" '); 
 ?>href="<?php bloginfo('url'); ?>">Home</a></li>
    <?php wp_list_pages('depth=1&title_li='); ?>

    </ul> </div>

The code in the parentheses after wp_list-pages is showing all pages you create and doing so can cause that list to grow quite large. You can just remove that code and hard code the actual pages you want in that area.

If you are a not familiar with editing WordPress themes make sure to copy all the code in the file and save it so you can restore any mistakes you might make!

Now just remove the bit of code in reading and replace it with a regular HTML formatted code like this:

    <div id="top-menu">
    <ul>
    <li><a <?php if (is_home()) echo('class="current" ');
    ?>href="<?php bloginfo('url'); ?>">Home</a></li>
    <a href="http://www.TheURL.com/" title="Page
    Title Here">Page Title Here</a>
    <a href="http://www.TheURL.com/" title="Page
    Title Here">Page Title Here</a>
    </ul> </div>

If you copy the above code to use it on your site and doesn’t work check for the proper format of all the quotes ” I tried to format them so they come through properly but may have missed one! To replace the curly quotes ” with regular ones just remove them and simply retype them again.

Now you can specify the exact page, or any URL for that matter simply by hard-coding it directly into your WordPress header.php file.

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...