wp_nav_menu( array(
'menu' => 'primary',
'walker' => new WPDocs_Walker_Nav_Menu()
)
);
// Custom Nav Menu walker class.
class WPDocs_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
// Depth-dependent classes.
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
$display_depth = ( $depth + 1); // because it counts the first submenu as 0
// Custom nav menu item custom field value i want to get in the $classes.
$menu_color = '"style="background-color: $item->Description""';
// Combine values of classes.
$classes = array(
'dropdown-menu',
( $display_depth % 2 ? 'menu-odd' : 'menu-even' ),
( $display_depth >=2 ? 'sub-sub-menu' : '' ),
'menu-depth-' . $display_depth,
''. $menu_color
);
$class_names = implode( ' ', $classes );
// Build HTML for output.
$output .= ($depth == 0) ? "\n" . $indent . '<ul class="' . $class_names . '">' . "\n" . "\n <div class=\"megamenu-content\">\n" . "\n<div class=\"row\">\n" : "\n<ul class=\"elementy-ul\">\n";
}
// Start the element output codes from here.....
}
wp_nav_menu( array(
'menu' => 'primary',
'walker' => new WPDocs_Walker_Nav_Menu()
)
);
// Custom Nav Menu walker class.
class WPDocs_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
// Depth-dependent classes.
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
$display_depth = ( $depth + 1); // because it counts the first submenu as 0
// Custom nav menu item custom field value i want to get in the $classes.
$menu_color = '"style="background-color: $item->Description""';
// Combine values of classes.
$classes = array(
'dropdown-menu',
( $display_depth % 2 ? 'menu-odd' : 'menu-even' ),
( $display_depth >=2 ? 'sub-sub-menu' : '' ),
'menu-depth-' . $display_depth,
''. $menu_color
);
$class_names = implode( ' ', $classes );
// Build HTML for output.
$output .= ($depth == 0) ? "\n" . $indent . '<ul class="' . $class_names . '">' . "\n" . "\n <div class=\"megamenu-content\">\n" . "\n<div class=\"row\">\n" : "\n<ul class=\"elementy-ul\">\n";
}
// Start the element output codes from here.....
}