Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save valeriu/4ccee5aafb77d8fe160cdf866c5e178b to your computer and use it in GitHub Desktop.
Save valeriu/4ccee5aafb77d8fe160cdf866c5e178b to your computer and use it in GitHub Desktop.
Make parent link clickable in Bootstrap for Desktop with WordPress NavWalker
if (wp_is_mobile()){
$atts['href'] = '#';
$atts['data-toggle'] = 'dropdown';
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
$atts['class'] = 'dropdown-toggle nav-link';
$atts['id'] = 'menu-item-dropdown-' . $item->ID;
} else {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
$atts['class'] = 'dropdown-toggle nav-link';
$atts['id'] = 'menu-item-dropdown-' . $item->ID;
}
/*
*Add this CSS in your (style.css) file.
*/
.dropdown:hover>.dropdown-menu {
display: block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment