Tutorials

How to Display Specific Pages/Links in WordPress Navigation Menu

Pinterest LinkedIn Tumblr

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.

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