skip to Main Content

Display Cart Link Shortcode in Mobile Menu Toggle

This snippet shows how you could easily display the cart_link shortcode in your mobile menu toggle area. Of course you can always just add the cart_link shortcode via Theme Panel > Custom Actions instead of using code. Also if you are using a newer "Flex" header style you can simply insert your header cart link via the "Header Aside" field in the Customizer and it will display on mobile devices.

/**
 * Display the cart_link shortcode inside the mobile menu toggle area.
 *
 * @link https://total.wpexplorer.com/docs/snippets/display-cart-link-shortcode-in-mobile-menu-toggle/
 */
add_action( 'wpex_hook_mobile_menu_toggle_bottom', function() {
    echo do_shortcode( '[cart_link]' );
} );
All PHP snippets should be added via child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)
Back To Top