RSS Feed for This PostCurrent Article

Easier WordPress Page Navigation

One of the most common questions I see in regards to WordPress menus is “How do I add a ‘Home’ link to my navigation menu?”

Typically – in the past, I’ve answered by stating that you place a static line before the call to wp_list_pages();, and that’ll do it for you. But today, I found something that snuck up on me – a tag that WordPress uses that I’ve never heard of before: wp_page_menu();

This one’s a bit different. Basically, it calls in you wp_list_pages(); function, but strips and edits some stuff to make the addition of a (nameable!) Home page link. Before, you had to do this in your template file:

<ul>
<li><a href="<?php bloginfo('home'); ?>">Home</a></li>
<?php wp_list_pages('title_li='); ?>
</ul>

To provide the link to your home page in he list. but now, it’s as simple as this:

<?php wp_page_menu('show_home=1'); ?>

It already provides you with a “wrapping div” (defaults to “menu” but you can rename it), the opening and closing <ul> tags, and you can even add text/classes before the text (within the anchor link tags). Nice and clean, and very useful.

Unfortunately, I haven’t found a “wp_categories_menu();” – but maybe I’m just not looking hard enough!

read more about and from Shelly at her web design company Brass Blogs

Trackback URL

RSS Feed for This Post1 Comment(s)

  1. Naomi Nilesq | Apr 23, 2009 | Reply

    Oh yeah, I was all happy when I saw that one too! They should’ve made an announcement just for that!

Sorry, comments for this entry are closed at this time.

Bad Behavior has blocked 232 access attempts in the last 7 days.