0

I am working on this site for my own business and when I create a menu with child links, as per below image, only last child of that drop down menu, it actually clicks and loads a page.

enter image description here

enter image description here

If I click any of the parent links to that last child '1 gang', none of those will work.

enter image description here

But if I type the full URL with that path, http://x.x.x.x/test-products-only/ or any of the 2 subsequent child to that, pages load and do show the categories group.

So it not like page is disabled, seems that the parents get something like a noclick property or something.

I am not touching the code so far as it's just creating a few pages and then the menus from Appearance > Menus.

Any advise is appreciated.

Cheers.

1
  • It does seems to be the theme, if i change it to one of the default wordpress, menus do work – eLGusto Aug 8 '19 at 5:09
0

First you need to check which theme you are currently using. Then you need to make sure that the theme's menu supports the depth of objects which you are using.

The so called wp_nav_walker() (it's a build in WordPress PHP-class) is the function/class, which builds the menu on the frontend.

If the menu-walker does not support the array-parameter depth => 4, then the menu is not capable of outputting this depth of menus.

There may be other reasons for your menu to break, but that's how I would approach this problem.

You may want to read further about the WordPress menu walker here.

There is also a great tutorial about the menu navwalker on YouTube, which I highly recommend to understand what's going on under the hood.

See this link: Menu Nav Walker

Since you only vaguely mentioned that you might want to change the code, I'd propose that you contact the theme developer and ask if the menu supports this kind of menu structure.

In case you are able to code, watch the video and overwrite the default menu wp_nav_walker with your own and make sure that the html-output supports 4-levels of ul li > ul li > ul li > ul li.

You can also try to implement/rewrite a Navwalker from GitHub, for example:

Git Twittem Navwalker for Bootstrap 4

Be aware that this output is made for the css-framework Bootstrap.

0
0

Thanks for that. It does not work with any depth. But u might be on to something. This is what I was able to find related to a "walker" class in the theme.

If i look at the loaded code in the browser, i see that the

  • for that child has a 'not-click' class in it.

    class smarthome_top_bar_walker extends Walker_Nav_Menu {
    
    static protected $menu_bg_test;
    function start_el(&$output, $item, $depth = 0, $args = Array(), $id = 0) {
    
        $smarthome_class = "";
      if(is_object($args)){
            global $smarthome_count;
            $icon=$item->classes[1];
        if($item->mega_menu == 1) {
            $smarthome_class= 'wd_mega-menu';
        }
        $smarthome_icon = $item->mega_menu_icon ;
        self::$menu_bg_test = $item->mega_menu_bg_image;
            $indent = ($depth) ? str_repeat("\t", $depth) : '';
            $class_names = $value = '';
    
            $classes = empty($item -> classes) ? array() : (array)$item -> classes;
            $classes[] = ($item -> current) ? 'active' : '';
            $classes[] = ($args -> has_children) ? ' color-1 has-dropdown not-click' : '';
            $args -> link_before = (in_array('section', $classes)) ? '<label>' : '';
            $args -> link_after = (in_array('section', $classes)) ? '</label>' : '';
            $output .= (in_array('section', $classes));
            $class_names = ($args -> has_children) ? 'has-dropdown not-click '.$smarthome_class : '';
            $parent = $item -> menu_item_parent;
            if ($parent == 0) {
              $smarthome_count++;
            }
    
            $current_page = empty($item->classes[4]) ? '' : $item->classes[4];
            $class_names .= ' color-' . $smarthome_count .' '. $current_page ;
            $class_names = strlen(trim($class_names)) > 0 ? ' class="' . esc_attr($class_names) . '"' : '';
            $output .= $indent . '
            <li id="menu-item-' . $item -> ID . '"' . $value . $class_names  . '>';
    
            $attributes = !empty($item -> attr_title) ? ' title="' . esc_attr($item -> attr_title) . '"' : '';
            $attributes .= !empty($item -> target) ? ' target="' . esc_attr($item -> target) . '"' : '';
            $attributes .= !empty($item -> xfn) ? ' rel="' . esc_attr($item -> xfn) . '"' : '';
            $attributes .= !empty($item -> url) ? ' href="' . esc_url($item -> url) . '"' : '';
    
            $attributes .= ' class="has-icon"';
    
            $item_output = $args -> before;
            $item_output .= (!in_array('section', $classes)) ? '
            <a' . $attributes . '>' : '';
            if(($icon != '') and ($icon != '---- None ----'))  {
    
            $item_output .= '<i class="'.$smarthome_icon.' fa"></i> ';
            }
            $item_output .= $args -> link_before . apply_filters('the_title', $item -> title, $item -> ID);
            $item_output .= $args -> link_after;
            $item_output .= (!in_array('section', $classes)) ? '</a>' : '';
            $item_output .= $args -> after;
    
    
            $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
        }
    
    
    }
    
  • 1
    • if i edit the code, remove the class and clean the js function that assign that class, issue still there.. – eLGusto Aug 8 '19 at 6:13
    0

    Now I'm not sure what theme you're using, but it might be in the menu-settings. Although you can't see all the settings for the menu, unless you activate them in screen options (found in top right corner in controlpanel - see image below):

    enter image description here

    Sometimes, some extra menu options are hidden here, and by default, they're deactivated. They will be located under "Show advanced menu properties" - if so, please activate them, and you might be able to find some more options when you edit your menu-item, like in the image below:

    enter image description here

    If there are no options, then I'm afraid you'll have to customize the menu yourself, by using the WordPress menu walker, as mentioned by user3135691.

    Good luck - I hope you can fix it by using the settings, and save some time.

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.