×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Eric De Kock
Added: Feb 13, 2017 2:29 AM
Views: 16
Tags: no tags
  1. function add_search_to_wp_menu ( $items, $args ) {
  2.         if( 'primary' === $args -> theme_location ) {
  3. $items .= '<li class="menu-item menu-item-search">';
  4. $items .= '<form method="get" class="menu-search-form" action="' . get_bloginfo('home') . '/"><p><input class="text_input" type="text" value="Enter Text &amp; Click to Search" name="s" id="s" onfocus="if (this.value == \'Enter Text &amp; Click to Search\') {this.value = \'\';}" onblur="if (this.value == \'\') {this.value = \'Enter Text &amp; Click to Search\';}" /><input type="submit" class="my-wp-search" id="searchsubmit" value="search" /></p></form>';
  5. $items .= '</li>';
  6.         }
  7. return $items;
  8. }
  9. add_filter('wp_nav_menu_items','add_search_to_wp_menu',10,2);