• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to move secondary sidebar above content on mobile devices

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to move secondary sidebar above content on mobile devices

This topic is: resolved

Tagged: above content, mobile, moving sidebar above content, Secondary Sidebar

  • This topic has 18 replies, 4 voices, and was last updated 9 years, 10 months ago by khanh11166.
Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • August 20, 2015 at 10:55 am #163016
    selkin
    Member

    Use outreach pro theme with sidebar/content/sidebar layout.

    I would like the secondary sidebar (alt sidebar, which is the LEFT sidebar) to appear above the content when displayed on mobile devices. ideally, anything tablet sized (portrait) and below.

    here is the URL: http://209.95.59.111/~acquisit/blog/resources/

    Using this method: (http://www.billerickson.net/code/move-sidebar-content/)

    remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
    add_action( 'genesis_before_content', 'genesis_get_sidebar' );

    The primary sidebar is moved above content on mobile. But I would like the secondary sidebar content to be moved above the content.

    I also tried specifically removing the secondary sidebar and adding it before content:

    remove_action( 'genesis_after_content', 'genesis_get_sidebar_alt' );
    add_action( 'genesis_before_content', 'genesis_get_sidebar-alt' );

    So this is great in that it changes mobile behavior to how I would like it. BUT, it blows up layout(floats) in non-mobile browsers.

    Help?!

    BTW: the secondary/sectional nav in the secondary sidebar is generated using the BE SUBPAGES WIDGET plugin, which auto-generates subpage list/menu. Very nice for future maintenance by the client.

    Thanks

    http://209.95.59.111/~acquisit/blog/resources/
    August 20, 2015 at 1:31 pm #163036
    frobn
    Member

    You can use conditionals like is_iphone(), is_mobile() and is_tablet(). with the Mobble plugin

    August 20, 2015 at 3:05 pm #163044
    selkin
    Member

    Thanks Frobn.

    I installed plugin. Tried function below. It behaves as if only the remove/add lines are there (no mobile checking going on).
    From looking at examples, it seems that the "if" call needed to be within a function, but I do not know what the first add_action should be, so used 'template_redirect'. Perhaps that is the issue?

    remove_action( 'genesis_before_content', 'move_alt_sidebar_b4content' );
    	function move_alt_sidebar_b4content() {
    		if (!is_mobile()) {
    		remove_action( 'genesis_after_content', 'genesis_get_sidebar_alt' );
    		add_action( 'genesis_before_content', 'genesis_get_sidebar_alt' );
    		}
    	}
    
    August 21, 2015 at 6:31 am #163070
    frobn
    Member

    Did you fix the code? It appears to be working perfectly in firefox.

    I just found that there is a wp function to detect mobile so you may be able to eliminate the plugin.

    <?php
    if ( wp_is_mobile() ) {
    	/* Display and echo mobile specific stuff here */
    }
    ?>
    August 21, 2015 at 11:44 am #163085
    selkin
    Member

    I had found that also, but trying to take Sridhar's advice not to use it... found here.

    Conditional for mobile check in WordPress

    Cannot get this to work yet.

    August 21, 2015 at 5:19 pm #163109
    selkin
    Member

    frobn,

    Just for kicks, I decided to try the wp_is_mobile conditional (as I am not sure what shridhar is really saying. And, on first check, it seems like that is working as desired. : ) I will do further testing. Here is what I am using at this point...

    `if ( wp_is_mobile() ) {
    remove_action( 'genesis_after_content', 'genesis_get_sidebar_alt' );
    add_action( 'genesis_before_content', 'genesis_get_sidebar_alt' );
    }`

    Thanks for checking/help so far.

    August 22, 2015 at 2:36 pm #163192
    Brad Dalton
    Participant

    Use Media Queries http://www.studiopress.community/topic/restrict-content-width/#post-162451

    Conditionals for mobile devices are not accurate.


    Tutorials for StudioPress Themes.

    August 22, 2015 at 3:56 pm #163198
    selkin
    Member

    How can I call that function from a media query? Is that what you are saying? Or are you saying I should try and re-jigger everything using CSS and floats (which I believe would be quite a mess, if even possible)?

    Thanks.

    August 22, 2015 at 4:02 pm #163199
    Brad Dalton
    Participant

    PHP mobile conditional tags don't work properly.

    The best method is to use CSS which i linked to.

    You will need to write a test your rules which position elements at specific screen widths.


    Tutorials for StudioPress Themes.

    August 22, 2015 at 8:11 pm #163208
    selkin
    Member

    Thank you. Are you quite certain this specific requirement and situation is possible with CSS? My gut says no.

    August 22, 2015 at 8:39 pm #163210
    Brad Dalton
    Participant

    There is no other reliable way to do this. CSS Media Queries are the best.


    Tutorials for StudioPress Themes.

    August 23, 2015 at 7:38 am #163221
    frobn
    Member

    Besides accuracy media queries are simpler to implement. Reversing the floats on the primary and alternate sidebars at the breakpoint you want should accomplish it.

    Thanks Brad.

    August 24, 2015 at 6:16 am #163290
    selkin
    Member

    I would like the secondary sidebar (alt sidebar, which is the LEFT sidebar) to appear above the content when displayed on mobile devices. ideally, anything tablet sized (portrait) and below.

    In the page build/Genesis loop, content comes before sidebars. Swapping left/right sidebars with css still does not move the left sidebar's content before main page content.

    This appears to be working...

    remove_action( ‘genesis_after_content’, ‘genesis_get_sidebar_alt’ );
    add_action( ‘genesis_before_content’, ‘genesis_get_sidebar_alt’ );

    I understand you say the php mobile check is unreliable.

    How might I trigger that php code using a css media query? I did not think that was possible. Or are you saying I should scrap the get_sidebar_alt altogether and try to a) switch sidebar content order on mobile and b) make it appear above main content which flows first in the page build?

    Thanks.

    August 24, 2015 at 10:39 am #163310
    selkin
    Member

    I have left original url working with php mobile check. Looks fine in my testing.

    I also used the following approach as an alternative (hate using the "T" word again). Anyway, I used a clean install of outreach pro and assigned this in 860px screen.

    @media only screen and (max-width: 860px) {
    	.wrap {
    		padding-left: 5%;
    		padding-right: 5%;
    		display: table;
    		float: none;
    	}
    	.content-sidebar-wrap {
    		padding: 0;
    		display: table-footer-group;
      		float: none;
    	}
    	.sidebar-secondary {
    		display: table-header-group;
    		float: none;
    		width: 180px;
    	}

    Q: can I trigger php code using a css media query? If not, which of the two is the better approach and why (or is there some other approach)?

    SE

    August 24, 2015 at 10:40 am #163311
    selkin
    Member

    Oh, sorry... second table header/footer approach URL is here...

    http://209.95.59.111/~acquisit/test/

    Uggh.

    August 24, 2015 at 4:18 pm #163347
    Brad Dalton
    Participant

    I don't think CSS will trigger PHP. I'm sure you can use CSS without any PHP.


    Tutorials for StudioPress Themes.

    August 25, 2015 at 6:19 am #163408
    frobn
    Member

    In your acquisit/tesnt, at max-width 860px the alt sidebar moves to the top, then content, then primary at the bottom.

    From 861px to 1023px the alt sidebar drops below the primary leading me to believe you will find your problem in the query: (max-width: 1023px)

    August 25, 2015 at 6:40 am #163409
    selkin
    Member

    Thanks Brad and Frobn.

    Ok, so no triggering php from css.


    @Frobn
    , thanks...I did not include this in the media query for 1023 yet...final code was pending both of your sage feedback.

    August 25, 2015 at 9:44 am #163439
    khanh11166
    Member

    Could you please take alook at my website?
    Những bài tập thể dục giảm mỡ bụng tại nhà hiệu quả

  • Author
    Posts
Viewing 19 posts - 1 through 19 (of 19 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble