I was looking for a way to do this also, and found it’s very easy to do. Just copy and past the below code into your child-theme function.php file. If you put it in the parent themes function.php you will need to replace every time you update the theme.
/* ADD SEARCH BAR NAVIGATION BAR */
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
if( $args->theme_location == 'primary' )
$items .= '<li style="float: right; vertical-align: center;">' . $searchform . '</li>';
return $items;
}
You can also add a login – logout link with the following code. Copy and past into your child-theme functions.php file.
/* ADD LOGIN - LOGOUT LINK NAVIGATION BAR */
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
ob_start();
wp_loginout('index.php');
$loginoutlink = ob_get_contents();
ob_end_clean();
if( $args->theme_location == 'primary' )
$items .= '<li>'. $loginoutlink .'</li>';
return $items;
}
Note the theme location refers to the location you want the login – logout link to go. You can also place it in the header or footer menu by replacing:
if( $args->theme_location == 'header' )
if( $args->theme_location == 'footer' )
NOTE you must have one link in either menu for it to work.
Screenshot: