Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Need urgent help with mega menu

  • 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.

  • 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.

  • Updated

  • 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

  • Thank you Fernando brother it is working. but looks like broken
    https://share.getcloudapp.com/L1u8GRkQ

  • 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;
    }
  • It is working perfectly on desktop thank you brother. can you please check in mobile view it is not looking good

  • I updated the code above, can you try that instead?

  • Thank you brother 🙏 it working now

  • You’re welcome, Yasin!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.