Posted By

alp on 04/03/11


Tagged

wordpress theming


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

stonetatara
srdjan


How to automatically add a search field to your navigation menu | Wordpress


 / Published in: PHP
 

URL: http://www.wprecipes.com/how-to-automatically-add-a-search-field-to-your-navigation-menu

Place snippet in functions.php

  1. add_filter('wp_nav_menu_items','add_search_box', 10, 2);
  2. function add_search_box($items, $args) {
  3.  
  4. get_search_form();
  5. $searchform = ob_get_contents();
  6.  
  7. $items .= '<li>' . $searchform . '</li>';
  8.  
  9. return $items;
  10. }

Report this snippet  

You need to login to post a comment.