Snippets: Add New Widget Area Above Content on Mobile

This code will register a new widget area (Mobile Sidebar) above your site content for mobile only (to display at your mobile menu breakpoint).

// Register new widget area
add_filter( 'wpex_register_sidebars_array', function( $sidebars ) {
	$sidebars['my_mobile_sidebar'] = __( 'Mobile Sidebar', 'total' );
	return $sidebars;
} );

// Add new widget area to the top of content on mobile
function my_mobile_widget_area() {

	if ( ! is_active_sidebar( 'my_mobile_sidebar' ) ) {
		return;
	}

	echo '<div id="my-mobile-sidebar" class="show-at-mm-breakpoint">';
		dynamic_sidebar( 'my_mobile_sidebar' );
	echo '</div>';

}
add_action( 'wpex_hook_content_before', 'my_mobile_widget_area' );
All PHP snippets should be added via a child theme's functions.php file.