Hey Retrokevin,
I did some messing around and came up with this. Keep in mind I’m not a JS wizard.
You’ll need to create some files in your child theme (if you don’t have them already) to follow along here.
functions.php
/js/reorder-sidebars-mobile.js
In your functions.php you want to enqueue the script
<?php
/**
* Proper way to enqueue scripts and styles Child Theme
*/
function devdmbootstrap3_child_theme_scripts() {
wp_enqueue_script( 'reorder-sidebars-mobile', get_stylesheet_directory_uri() . '/js/reorder-sidebars-mobile.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'devdmbootstrap3_child_theme_scripts' );
In your reorder-sidebars-mobile.js file you can use this code
jQuery(document).ready(function( $ ) {
var mobilewidth = "767";
if ($(window).width() < mobilewidth) {
$('.dmbs-left').insertBefore('.dmbs-right');
}
$( window ).resize(function() {
if ($(this).width() < mobilewidth) {
$('.dmbs-left').insertBefore('.dmbs-right');
} else {
$('.dmbs-left').insertBefore('.dmbs-main');
}
});
});
The first function sets the “order” when the window is loaded. Moves the left column on top of the right column if mobilewidth threshold is hit.
The re-size function will ping every time the window is re-sized. I “think” this is triggered with a screen rotation so we are doubling up to cover all our bases. It will also put the left sidebar back when the threshold is detected as no longer hit.
Hope this helps!