<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Make WordPress Themes &#187; custom menus</title>
	<atom:link href="http://make.wordpress.org/themes/tag/custom-menus/feed/" rel="self" type="application/rss+xml" />
	<link>http://make.wordpress.org/themes</link>
	<description>Just another make.wordpress.org site</description>
	<lastBuildDate>Tue, 21 May 2013 00:06:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6-beta3-24330</generator>
	<atom:link rel='hub' href='http://make.wordpress.org/themes/?pushpress=hub'/>
		<item>
		<title>Custom Menus Implementation: Use theme_location instead of menu in wp_nav_menu()</title>
		<link>http://make.wordpress.org/themes/2012/03/16/custom-menus-implementation-use-theme_location-instead-of-menu-in-wp_nav_menu/</link>
		<comments>http://make.wordpress.org/themes/2012/03/16/custom-menus-implementation-use-theme_location-instead-of-menu-in-wp_nav_menu/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 15:18:38 +0000</pubDate>
		<dc:creator>Chip Bennett</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[custom menus]]></category>

		<guid isPermaLink="false">http://make.wordpress.org/themes/?p=826</guid>
		<description><![CDATA[In several recent Theme reviews, I have noticed that Themes are implementing custom navigation menus incorrectly, primarily due to the arguments passed to wp_nav_menu. For example: &#60;?php wp_nav_menu( array( 'menu' =&#62; 'primary-nav' ) ); ?&#62; Notice what&#8217;s wrong there? Yeah: the 'menu' parameter. By passing the 'menu' parameter, the Theme is telling WordPress, &#8220;display the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In several recent Theme reviews, I have noticed that Themes are implementing <a href="http://codex.wordpress.org/Navigation_Menus">custom navigation menus</a> incorrectly, primarily due to the arguments passed to <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu"><code>wp_nav_menu</code></a>. For example:</p>
<blockquote>
<pre>&lt;?php
wp_nav_menu( array(
    'menu' =&gt; 'primary-nav'
) );
?&gt;</pre>
</blockquote>
<p>Notice what&#8217;s wrong there? Yeah: the <code>'menu'</code> parameter.</p>
<p>By passing the <code>'menu'</code> parameter, the Theme is telling WordPress, &#8220;<em>display the user-defined menu with  this slug</em>&#8220;. This parameter will only work in one of two cases:</p>
<ol>
<li>As a matter of serendipity, the user has created a custom menu with the slug &#8220;primary-nav&#8221; (i.e. a custom menu named &#8220;Primary Nav&#8221;)</li>
<li>As a matter of chance, the user has only defined one custom menu, which WordPress will use as an alternate, when it cannot find a menu with the slug &#8220;primary-nav&#8221;</li>
</ol>
<p>In pretty much all other cases, the user-defined menu assigned to a given Theme location will not output correctly.</p>
<p>Instead, Themes should <em>only and always</em> pass the <code>'theme_location'</code> parameter to <code>wp_nav_menu()</code>. The <code>'theme_location'</code> parameter corresponds to the array keys passed to <a href="http://codex.wordpress.org/Function_Reference/register_nav_menus"><code>register_nav_menus()</code></a>, like so:</p>
<blockquote>
<pre>register_nav_menus( array(
    'primary-nav' =&gt; "Primary Menu",
    'footer-nav' =&gt; "Footer Menu"
) );</pre>
</blockquote>
<p>The array key is the <code>'theme_location'</code>, and the array value is the title that displays under the &#8220;Theme Locations&#8221; meta box on the <a href="http://codex.wordpress.org/Appearance_Menus_Screen">Dashboard -&gt; Appearance -&gt; Menus screen</a>. So, Themes should pass those array keys to calls to <code>wp_nav_menu()</code>, like so:</p>
<blockquote>
<pre>&lt;?php
wp_nav_menu( array(
    'theme_location' =&gt; 'primary-nav'
) );
?&gt;</pre>
</blockquote>
<p>That way, custom navigation menus will work properly:</p>
<ol>
<li>Theme registers custom menu Theme locations, via <code>register_nav_menus()</code></li>
<li>User creates custom menus, via the Dashboard -&gt; Appearance -&gt; Menus screen</li>
<li>User assigns custom menus to Theme locations, via the &#8220;Theme Locations&#8221; meta box on the Dashboard -&gt; Appearance -&gt; Menus screen</li>
<li>Theme outputs custom menus in appropriate locations within the Theme template, via <code>wp_nav_menu()</code></li>
</ol>
<p>Hopefully this post will help eliminate a few Theme development headaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://make.wordpress.org/themes/2012/03/16/custom-menus-implementation-use-theme_location-instead-of-menu-in-wp_nav_menu/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
