Advertisement
meetsos

Add Search Bar in Header

Apr 22nd, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);
  4. function add_search_box_to_menu( $items, $args ) {
  5.     if( $args->theme_location == 'primary' )
  6.         return $items.get_search_form();
  7.  
  8.     return $items;
  9. }
  10.  
  11. // ή, εναλλακτικά
  12.  
  13. add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);
  14. function add_search_box_to_menu( $items, $args ) {
  15.     if( $args->theme_location == 'primary' )
  16.         return $items."<li class='menu-header-search'><form action='http://example.com/' id='searchform' method='get'><input type='text' name='s' id='s' placeholder='Search'></form></li>";
  17.  
  18.     return $items;
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement