---
title: More control over wp_nav_menu()
author: George Mandis <george@mand.is>
date: 2011-07-29
tags: post
---

I can't count how many times I've Googled some random error or function and found the answer I needed on a personal blog for someone I've never heard of. Because of that, I try to make a point to document fixes to tiny, nagging problems as I discover them.

In that vein, here's a tip for using `wp_nav_menu()` in your WordPress theme: You may want to have portions of your menu dynamic and controlled by WordPress' built-in menu system, but also include static elements at the bottom of the menu &mdash; maybe something like a login link that changes depending on whether or not the user is already logged-in or a members-only area.  By default calling `wp_nav_menu()` renders something like this:

	<ul class="menu">
		<li><a href="link1.html">Link 1</a></li>
		<li><a href="link2.html">Link 2</a></li>
	</ul>

That's nice and convenient, but you can't hard-code any additional `<li>` elements to this list in your theme.  What you can do though is render the list items *without* the encapsulating `<ul>` element like this:
	
	wp_nav_menu( "items_wrap" => '%3$s', "container" => "");

This means you'll have to add the encapsulating `<ul>` element theme.  The final product would probably look like this:
	
	<ul>
		<?php wp_nav_menu( "items_wrap" => '%3$s', "container" => ""); ?>
		<li><a href="login.html">Members Login</a></li>
		<?php if ($member_is_logged_in_and_this_variable_name_is_too_loooooong) {
		<li><a href="members.html">Members Only Area</a></li>
		<?php } ?>
	</ul>

Nice little trick that makes the built-in menu management a little more flexible.