• I’ve added child links to a parent menu item and now the parent item is not linkable. Need the parent to still be clickable. Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @phoenixim,

    I apologize for the late reply- seems we didn’t receive a notification of your post for some reason.

    There isn’t currently an option to change this behavior, but if you’re using a child theme it’s possible with a bit of tweaking.

    If you have an active child theme and are comfortable making a couple of careful edits to the code, let me know and I can write up the steps required.

    Thanks for getting in touch, and I apologize again for the delay!

    Thread Starter phoenixim

    (@phoenixim)

    Hello Steven,

    I have a child theme and can edit it so any steps would help. Thanks!!!

    Rob

    Hi Rob,

    I am so sorry- we didn’t receive a notification again, even though we’re subscribed to the topic.

    If you still need this functionality, here are the steps to achieve it:

    1. Copy (not move) /includes/wp_bootstrap_navwalker.php from your parent theme into the same location within your child theme.

    2. In the child copy of this file, replace this code around line 128:

    // If item has_children add atts to a.
    if ( $args->has_children && $depth === 0 ) {
    	$atts['href'] = '#';
    	$atts['data-toggle'] = 'dropdown';
    	$atts['class'] = 'dropdown-toggle';
    	$atts['aria-haspopup'] = 'true';
    	$atts['aria-expanded'] = 'false';
    } else {
    	$atts['href'] = ! empty( $item->url ) ? $item->url : '';
    }

    With this code:

    //For clickable parent nodes
    if ( $args->has_children && $depth === 0 ) {
    	$atts['class'] = 'dropdown-toggle';
    	$atts['aria-haspopup'] = 'true';
    	$atts['aria-expanded'] = 'false';
    }
    $atts['href'] = ! empty( $item->url ) ? $item->url : '';

    3. In your child functions.php, add this line just after the opening PHP tag:
    require get_theme_file_path('/includes/wp_bootstrap_navwalker.php');

    If you have any trouble, just let us know- I’ll try to manually keep an eye on this thread since we’re not receiving notifications.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Make parent menu item clickable’ is closed to new replies.