Support » Theme: GeneratePress » WP Menu Cart Next To Navigation Search On Mobile Devices

  • About a year or 2 ago, we tried the following filter to postion the mini cart on mobile devices:

    add_action( ‘generate_inside_mobile_menu_bar’,’tu_add_to_mobile_bar’ ); function tu_add_to_mobile_bar() { ?> <div class=”mobile-cart”> <?php echo do_shortcode( ‘[your-shortcode]’ ); ?> </div> <?php }

    With the following CSS:

    .mobile-cart { float: right; }

    This set the position for the WP Menu Cart. All we had to do, was create a shortcode for the WP Menu Cart plugin.

    We left this for a while, and have now come back to this, and the filter and CSS don’t appear to work anymore, whereas they did a year or two ago.

    Just wanted to know if anything has changed on the GeneratePress free theme, which would involve the need for the above code to be updated?

    If so, would anyone know how to adjust the above code for this to work?

    Kind Regards,

    Andrew

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there,

    try changing this: generate_inside_mobile_menu_bar to generate_menu_bar_items

    Thread Starter Andrew1977

    (@andrew1977)

    Hi David,

    Thank you for such a super quick reply.

    Have tried that, and it’s still not working.

    It’s got me baffled!

    Kind Regards,

    Andrew

    Thread Starter Andrew1977

    (@andrew1977)

    Hi David,

    Really strange thing, just noticed. We can get the original code to work if we enable the search box in the theme settings.

    If the search box is disabled in the theme settings the code doesn’t work!

    Even moved the mobile menu bar to the far left with some CSS, when the search box is disabled, and still the code doesn’t work.

    Not sure why the search box needs to be enabled for the code to work?

    Kind Regards,

    Andrew

    • This reply was modified 10 months, 2 weeks ago by Andrew1977.
    ying

    (@yingscarlett)

    Hi @andrew1977

    The generate_inside_mobile_menu_bar hook only exists when the nav search is enabled, for more info:

    https://docs.generatepress.com/article/generate_inside_mobile_menu_bar/

    Thread Starter Andrew1977

    (@andrew1977)

    Hi @yingscarlett

    Many thanks for providing this information.

    All makes sense now!

    Would you know how we could tweak the original filter to work, when the search navigation is disabled?

    Had a look at the link you sent, but couldn’t quite work out how to change the filter for this to work?

    Kind Regards,

    Andrew

    ying

    (@yingscarlett)

    In this case, like David suggested, try changing generate_inside_mobile_menu_bar to generate_menu_bar_items

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP Menu Cart Next To Navigation Search On Mobile Devices’ is closed to new replies.