I dont want to have dropdown (select - options) in my wordpress menu, even in mobile or lower width devices. I know I can use css to hide it, but I want to remove it at all. I googled for an hour and I found that I should use a custom walker on Roots!!!! but I dont know whats that and how. please help me, I am a newby.
3 Answers
We can use depth parameter of wp_nav_menu
to set how many levels menu walker traverses.
wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' , 'depth' => 1) );
You can create a child theme so that updates won't override during updates.
Create child theme and copy code from header.php
of parent theme then replace the code
wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' ) );
with the above code.
More Info: child theme
Since WP v3.3.0
you can use filter wp_nav_menu_args
to alter arguments of function wp_nav_menu
that used to display a navigation menu. Add this code in functions.php
of your theme files. You can change functions name wpse155177_nav_menu_args
.
/**
* @see wp_nav_menu()
*
* @return array $args Array of wp_nav_menu() arguments.
*/
add_filter( 'wp_nav_menu_args', 'wpse155177_nav_menu_args', 1, 1 );
function wpse155177_nav_menu_args( $args )
{
//lookup theme_location ie: header-menu
if ( isset( $args['theme_location'] ) && 'header-menu' == $args['theme_location'] ) {
$args['depth'] = 1; //levels of the hierarchy are to be included
}
return $args;
}
Simply try to move in menu settings "menu voices"(pages as :home, who we are, what to do, etc) alling them one under another.
js/functions.js
exists a functioninitMainNavigation
. This function creates the dropdown button.