Specify WordPress Navigation Page Links

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

Similar Posts:



Tags:

If you liked this post, feel free to leave a comment that is relevant to the post or subscribe to the feed and get future articles delivered to your feed reader.

Sorry but due to the spamming of a few all comments are moderated and will appear when approved and all drive-by comments will be deleted!

Comments

[...] ‘hard code’ any URL in the WordPress navigation bar as this previous post explains: Specify WordPress Navigation Page Links Customize WordPress WordPress WordPress Guide WordPress guides Share This Gregarious [...]

Thanx your article

Reply

Hi, I am a complete newbie with no clue what I am doing, the worst kind of user.. just enough to be dangerous. I enter my wordpress entries directly from my website, and as such they have the format of my website, so how do I use such things as listing only the last post ? or the summary and more option? When I change these in the admin they are really only changing them on wordrpess external display which incidently and probably correctly does not display the post I write from whithin the website.. Should they be the same? Should entries made from /myblog/admin show up on main page (at website above) where I typically write my entries? is it just a path thing.. hope this makes sense.

Reply

Sorry Lisa, but no, it makes no sense to me at all.

Reply

Thank you so much for this educational help – it has been of much help.

Pino
http://www.LanSmith.com

Reply

Thank you so much for this educational help – it has been of much help.

Pino
http://www.LanSmith.com

Reply

Thank you very much, just what I needed. And thank you for the backlink :)

nicholas

Reply

Thank you so much for this post. One question.

How would I change the TXT font of each link.

For instance, if my top menu bar says

Home About Us Donate Contact

How could I change the sizes of these links? Thank you

Reply

Stone… that is much harder to explain because all WordPress themes are coded differently. That would need edited in the style.css file and the navigation bar could be called anything in there. if you are lucky it might be called nav or bar, then you would change the text size in the stylesheet.

Sorry but if you haven’t noticed I really don’t get that deep into theme code. Simply because there are as many different variations of how a theme is coded as there are themes.

Reply

What does this do? change links to RED??? omg. You dont have to do this. Just open your header.php, and find the navigation, usually it has a class named “menu” or “navigation” or with “wp_list_pages()”.. Then open your style.css find the class of the navigation there. And change the color. You can add the name red (as it is recognized) or hex code. For more color names just visit:
http://www.w3schools.com/HTML/html_colornames.asp

Reply

Jeff  Replied:

No it removes the pages and shows how to hard code any URL of your choice in. Any other words of wisdom you care to share Mr. ExpertWordPress?

Reply

Is it possible to also be able to add subpages? That would be good.

Reply

Jeff  Replied:

Probably but I never tried it, there are plugins for subpages so the code to add them to a nav bar should be available.

Reply

Leave a comment
Drive-By comments will be deleted! Like "Thanks for sharing", "Nice post", or any other text that doesn't contribute to the discussion. If you ask a very specific question about your particular WordPress theme, it will probably be deleted. I can fix your WordPress site but for a price. If you ask a question like "Why don't my blog work right", it will be deleted. If you ask a question about your WordPress site without a leaving a link to it, it will be deleted. The point is to ask questions and or comment on the the actual content of the post, and to please use some common sense. All comments are moderated and will appear when approved. Thank you.

(required)

(required)