[Resolved] Changing Sidebar order on mobile

Home Forums Support [Resolved] Changing Sidebar order on mobile

Home Forums Support Changing Sidebar order on mobile

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #112361
    James Frost

    I’m wanting to change the order in which the sidebars appear when viewing the site on a small screene. At the moment, the left sidebar is showing first, followed by the right sidebar. Can these be switched around so the right sidebar shows first?

    thanks in advance,

    James

    #112362
    Tom
    Lead Developer
    Lead Developer

    Had another user request this the other day.

    Off to bed right now (12AM), but will look into this tomorrow. There should be something I can do.

    Thanks! πŸ™‚

    #112503
    Tom
    Lead Developer
    Lead Developer

    Ok, best way to do this is to use jQuery.

    Paste this into the wp_footer hook using GP Hooks, or enqueue it as a .js file:

    <script>
    jQuery(window).load(function($) {
    	var mobile, widthTimer, leftSidebar, rightSidebar;
    	mobile = jQuery( '.menu-toggle' );
    	leftSidebar = jQuery( '#left-sidebar' );
    	rightSidebar = jQuery( '#right-sidebar' );
    			
    	function generateRearrangeSidebars() {
    		
    		if ( leftSidebar.is( ':visible' ) && leftSidebar.is( ':visible' ) ) {
    	
    			if ( mobile.is( ':visible' ) ) {
    				rightSidebar.insertAfter('#primary');
    			} else {
    				rightSidebar.insertAfter('#left-sidebar');
    			}
    		
    		}
    	}
    			
    	if ( mobile.is( ':visible' ) ) {
    		generateRearrangeSidebars();
    	}
    			
    	jQuery(window).resize(function() {
    		clearTimeout(widthTimer);
    		widthTimer = setTimeout(generateRearrangeSidebars, 100);
    	});
    });
    </script>
    #112527
    James Frost

    Tom,

    fantastic – thanks for the quick response, that’s perfect.

    Loving this theme.

    Best regards

    James

    #112590
    Tom
    Lead Developer
    Lead Developer

    Perfect, happy to help πŸ™‚

    #492709
    Bruno

    Mmm, this post is from 2015…now 2018!

    Tom, there MUST be a wisywyg way to do this?

    Trying in customizer but they don’t hold their positions…

    Thanks,
    Bruno

    #492801
    David
    Staff
    Customer Support
    #493047
    Tom
    Lead Developer
    Lead Developer

    Yea, Flexbox is definitely the way to go now πŸ™‚

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