Search bar and Login on navigation menu
-
Hi, I was looking for some help with the WP default theme V1.1, I added a search form to the nav menu (PHP and CSS code Below) but the search bar is showing at the right side of the menu, and I wanted it to be in the middle, between the Blog Name and the Navigation Menu Links.
Ej: MySiteName Search Bar Link1 Link2 Link3
Apart from that I Wanted to implement a login form for buddypress users at the nav menu (Search bar Shows only to logged in users)
Thanks for the help:
PHP Code:
function add_search_to_wp_menu ( $items, stdClass $args ) {
if(is_user_logged_in()) {
if( ‘primary’ === $args -> theme_location ) {
$items .= ‘<li class=”menu-item menu-item-search”>’;
$items .= ‘<form method=”get” class=”menu-search-form” action=”‘ . get_bloginfo(‘home’) . ‘/”><p><input class=”text_input” type=”text” value=”” name=”s” id=”s” onfocus=”if (this.value == \’\’) {this.value = \’\’;}” onblur=”if (this.value == \’\’) {this.value = \’\’;}” /></p></form>’;
$items .= ”;
}
return $items;
}
}
add_filter(‘wp_nav_menu_items’,’add_search_to_wp_menu’,10,2);CSS Code:
.menu-search-form input#s.text_input {
border-radius:0;
width:450px;
margin-right:15px;
margin-left:10px;
font-size:12px;
-webkit-transition:all .3s ease-in-out;
-moz-transition:all .3s ease-in-out;
-ms-transition:all .3s ease-in-out;
-o-transition:all .3s ease-in-out;
outline:none;
border:1px solid #DDD
}
- The topic ‘Search bar and Login on navigation menu’ is closed to new replies.