Materialize css framework and dropdown menu problem.
-
Hello!
Im using Materialize Css framework to create Material Design theme.
I have problem with making dropdown menu available onto WordPress.First of all I need to have submenu structure which have special Id and class=”dropdown-content” (ul -> li -> a structure). (There it is)
Second one is to have :
– class=”dropdown-button”
– href=”#!”
– data-activates=”dropdown1″
in link tag (a).After clicking of that menu I just want to see sub menu.
In my function.php i added this :
function add_menu_atts( $atts, $item, $args ) { if (in_array('menu-item-has-children', $item->classes)) { $atts['class'] = "dropdown-button"; $atts['href'] = "#!"; $atts['data-activates'] = 'dropdown1'; } return $atts; } add_filter( 'nav_menu_link_attributes', 'add_menu_atts', 10, 3 );
To add class, link, and data-activates atributes to link which have children/s.
And second part of code is :function start_lvl( &$output, $depth = 0, $args = array() ){ $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul id=\"dropdown2\" class=\"sub-menu dropdown-content\">\n"; }
I use it to add id of all ul childrens. (For now im just trying only one submenu)
There is my menu : https://scr.hu/2G4W19Ass you can see here: https://scr.hu/BWPkNP I have it all done but I need to have the same ID on the “ul” like on “a” data-activates.
But when I change one of this 2 parts of code for the same all sub menu structure disapear.
And in code it look like : https://scr.hu/nM2wJMPlease help!
- The topic ‘Materialize css framework and dropdown menu problem.’ is closed to new replies.