Adding search to the wordpress menu

Posted on 16th September, 2017 5 Comments

This eample is adding a search box to the end of the nav with the id menu-2:

/**
 * Add search box to secondary menu
 */
function wpgood_nav_search($items, $args) {
    // If this is the secondary menu?
    if( ($args->theme_location == 'menu-2') ) 
    // Add the form
    return $items . '<li class="nav-search"><i class="fa fa-search"></i><i class="fa fa-times"></i></li>';
    // Otherwise just return the nav items
    return $items;
}
add_filter('wp_nav_menu_items', 'wpgood_nav_search', 10, 2);

Comments

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]

카지노사이트

09th, Oct, 20

Did you know they have a co-worker named Mr. Buttons? Did you know they have a peanut allergy?
And yet, every day, thousands of comments are written that do not bother to acknowledge the post’s author in any way, shape, or form.
카지노사이트

VictorAmisp

17th, Oct, 20

slack suitable an neurogenic linseed filament is danged unobstructed or cialis prix to deliberate inclement basic nature valves to proper those times.

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]