jcadima
4/7/2015 - 2:59 PM

Make Wordpress Bootstrap Parent Menus Clickable

Make Wordpress Bootstrap Parent Menus Clickable

<?php
// reference :
// http://stackoverflow.com/questions/25692514/bootstrap-how-do-i-make-dropdown-navigation-parent-links-an-active-link

// 1. Open up the wp-bootstrap-navwalker.php with your editor and look up for line approx: 83
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
   $atts['href']        = '#';
   $atts['data-toggle'] = 'dropdown';
   $atts['class']           = 'dropdown-toggle';
} else {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
}

// 2. Change this piece of code to:
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
   //$atts['data-toggle']   = 'dropdown';
   $atts['class']           = 'dropdown-toggle';
} else {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
}


// 3. This will make the parent Menus clickable, but it will disable drop-down,
// to fix this problem go to your styles.css and put:

.dropdown:hover .dropdown-menu {
    display: block;
}

// 4. This will re-enable drop-down on hover