-
Anonymous
Hi team, I need urgent help how to create a mega menu.
I have follow a instruction as mentioned on the thread https://generate.support/topic/assistance-needed-in-creating-a-mega-menu-with-generateblocks/ . But didn’t get success. Please help me to achieve this.I have add login details in private information.
-
Fernando
Hi Yasin,
It seems this topic somehow slipped through our system. We’ll try to assist, but please take note that this issue is beyond our scope.
Let’s try to debug. Can you update your PHP code to this:
add_filter( 'walker_nav_menu_start_el', 'db_sub_menu_item_hook', 10, 4 ); function db_sub_menu_item_hook( $item_output, $item, $depth, $args ) { // Specify menu item class to target $class_string = 'gp_mega_item'; $menu_item_classes = $item->classes; if ( empty( $menu_item_classes ) || !in_array( $class_string , $menu_item_classes ) ) { return $item_output; } $menu_item_slug = $item->post_name; // create custom hook from $class_string and $menu_item_slug // example result gp_mega_menu-{menu-item-name} $custom_hook_name = $class_string . '_' . $menu_item_slug; // Add our common and specific hooks ob_start(); ?> <ul class="sub-menu custom-sub-menu"> <li> <?php do_action('gp_before_mega_item'); ?> <?php do_action($custom_hook_name); var_dump($custom_hook_name); ?> <?php do_action('gp_after_mega_item'); ?> </li> </ul> <?php $custom_sub_menu_html = ob_get_clean(); // return the output after the menu items anchor $item_output .= $custom_sub_menu_html; return $item_output; }
Let’s try to see what value the hook name is.
-
Anonymous
Updated
-
Fernando
Revert the PHP snippet to this:
add_filter( 'walker_nav_menu_start_el', 'db_sub_menu_item_hook', 10, 4 ); function db_sub_menu_item_hook( $item_output, $item, $depth, $args ) { // Specify menu item class to target $class_string = 'gp_mega_item'; $menu_item_classes = $item->classes; if ( empty( $menu_item_classes ) || !in_array( $class_string , $menu_item_classes ) ) { return $item_output; } $menu_item_slug = $item->post_name; // create custom hook from $class_string and $menu_item_slug // example result gp_mega_menu-{menu-item-name} $custom_hook_name = $class_string . '_' . $menu_item_slug; // Add our common and specific hooks ob_start(); ?> <ul class="sub-menu custom-sub-menu"> <li> <?php do_action('gp_before_mega_item'); ?> <?php do_action($custom_hook_name); ?> <?php do_action('gp_after_mega_item'); ?> </li> </ul> <?php $custom_sub_menu_html = ob_get_clean(); // return the output after the menu items anchor $item_output .= $custom_sub_menu_html; return $item_output; }
Then, in you Hook Element, use this custom hook instead:
gp_mega_item_service-2
-
Anonymous
Thank you Fernando brother it is working. but looks like broken
https://share.getcloudapp.com/L1u8GRkQ -
Fernando
Try adding this through Appearance > Customize > Additional CSS:
@media (min-width: 1024px){ .gb-container.gb-container-6ac6a19b { min-width:100vw; } } .inside-navigation.grid-container { position: static; }
-
Anonymous
It is working perfectly on desktop thank you brother. can you please check in mobile view it is not looking good
-
Fernando
I updated the code above, can you try that instead?
-
Anonymous
Thank you brother 🙏 it working now
-
Fernando
You’re welcome, Yasin!
- You must be logged in to reply to this topic.