title: adding menu items in wordpress
body: <p>I am using wp_nav_menu() and I want to add the search box as a part of the menu.</p>
  
  <p>I am having trouble figuring it out and was hoping for some assistance:</p>
  
  <p>My code:</p>
  
  <pre><code>        &lt;?php 
          $args = array('theme_location' =&gt; 'primary', 'container' =&gt; false);
          wp_nav_menu( $args ); 
          ?&gt;
  </code></pre>
  
  <p>Now I want to add an additional &lt;li&gt; element to the end or the menu &lt;ul&gt; and all I want in the &lt;li&gt; is the output of:</p>
  
  <pre><code>        &lt;?php get_search_form();?&gt;
  </code></pre>
  
  <p>Can this be done?</p>
  
  <p>functions.php:</p>
  
  <pre><code>add_action('init', 'register_top_menu');
  
  function register_top_menu() {
      register_nav_menu('primary', __('Top Menu', 'leeaenergy'));
  }
  
  
  add_filter('wp_nav_menu_items','add_search', 10, 2);
  
  function add_search($items, $args) {
  
      if( $args-&gt;theme_location == 'primary' )
      return $items . '&lt;li&gt;'.get_search_form().'&lt;/li&gt;';
  }
  </code></pre>