Issue primary menu with submenus

Hello and thanks for your beautiful themes.

After an update of Dazzling in version 2.0.4, I have a problem with my primary menu who has secondary menus.

My web site: http://www.lepratique.fr/

Since the update, when I put my mouse over the button “NOS RÉALISATIONS”, the link of this page is LE PRATIQUE, usineur et assembleur en Sarthe and when I click on this button, my sub-menu appears.

BEFORE the update, the link was Réalisations : LE PRATIQUE usine et assemble vos composants and after the click, the page was directly displayed (without the submenus).

Thanks a lot for your answer.

My configuration:
— Wordpress 4.5
— Child theme

Hi @zebre6,

I hope you are well today and thanks for posting here.

This is the default behavior of Bootstrap framework that we have used in our theme. You can confirm it on the following Bootstrap framework nav menu demo page.

http://getbootstrap.com/examples/navbar/

If you want to make the top level menu link visited on clicking on it then you can use the solution posted in the following reply.

https://colorlibsupport.com/t/correct-menu-structure/page/2/#post-28178

Best Regards,
Movin

Thanks a lot for your fast answer.

First, when I tried to download the attached file of the post you gave me, I have an error (see the attached picture).

So I created a PHP file with the code of this post: https://colorlibsupport.com/t/correct-menu-structure/page/2/#post-29846

And it works FINE !!!

An other question: is it possible to use this plugin with other Wordpress Themes that use Bootstrap framework?

Thanks a lot.

Hello, it’s me again.

The solution you gave me doesn’t work on mobile devices. I think that is normal.
To make this solution works with mobile devices, what kind of code I must change?

I hope there is a solution.

Best regards

You are most welcome here :slight_smile:

Yes that solution doesn’t work on mobile devices because we have developed it so as if we enable it to work on mobile devices then the sub menus won’t appear on tabbing on the parent menu and instead we gets redirected to parent menu page.

If you still want to make it work on mobile devices then instead use the below modified code.



<?php 
/*
Plugin Name: Colorlib Plugin
Description: Quick Custom Solution Plugin for Implementing Custom Solution.
Version: 1.0.0
Author: Movin
Author URI: http://freewptp.com/
License: GNU General Public License (Version 2 - GPLv2)
*/

function  custom_nav_menu_link_attributes( $atts, $item, $args ){
  if ( $args->has_children  ) {
            $atts['href'] = ! empty( $item->url ) ? $item->url : '';
    }
  return $atts;
}
add_filter( 'nav_menu_link_attributes', 'custom_nav_menu_link_attributes', 99, 3 );

function func_make_menu_clickable(){
 ?>
  <script type="text/javascript">
    jQuery(document).ready(function($){      
        $('li.menu-item a').click(function(){
          window.location = $(this).attr('href');
        });
    });
  </script>
  <style type="text/css">
  .menu-item-has-children:hover > ul {
  display: block;
}
  </style>
<?php 
}
add_action('wp_footer', 'func_make_menu_clickable', 1);

Hello Movin!

Thanks for this new code.

IT WORKS PERFECTLY! YOU’RE THE KING!

Have a nice week, see you soon…

You are always welcome here :slight_smile: