• 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

Prevent Sidebar from loading

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 › General Genesis Framework Discussions › Prevent Sidebar from loading

This topic is: not resolved

Tagged: mobile, Sidebar

  • This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by EatDrinkDeals.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 25, 2021 at 11:30 am #503835
    EatDrinkDeals
    Participant

    I have a sidebar on my site desktop view and it is not shown on mobile but it still is being loaded. I can tell this by looking at pagespeed insights and lighthouse. How can I prevent the sidebar from being loaded on mobile devices? My site is http://www.seniordaily.com
    Below is the CSS I use to prevent the sidebar from being displayed on mobile. It works fine on that but my mobile pagespeed score is poor because the sidebar appears to be loaded then suppressed.

    @media
    only screen and (max-width : 768px) {
    .sidebar-primary {
    display: none; }
    .site-header .wrap {
    padding: 13px;
    padding-bottom: -19px;
    margin-right: 0px;
    margin-bottom: -77px;
    }
    }

    https://www.seniordaily.com/
    April 25, 2021 at 11:40 am #503836
    EatDrinkDeals
    Participant

    I forgot to add that I am using Magazine Pro 3.7.0 and Genesis 3.3.3. Also here is my pagespeed:
    https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.seniordaily.com%2F

    April 25, 2021 at 1:54 pm #503840
    EatDrinkDeals
    Participant

    To address this I did the following, if anyone thinks this was the wrong approach please reply.
    1. Made a copy of sidebar.php from the Genesis folder.
    2. Edited to add this line at the top
    if ( ! wp_is_mobile() ) {

    3. And this at the bottom

    } else {
    // Do nothing
    }
    4. Uploaded the file to the Magazine Pro themes folder

    I think that this turns all the sidebar function into a no-op on mobile devices.

    April 25, 2021 at 2:53 pm #503842
    andytc
    Participant

    I wouldn't do that , I'd just add some code to the childtheme functions.php to remove the sidebar - something like below

    if (wp_is_mobile()) {
       remove_action ('genesis_sidebar','genesis_do_sidebar');
    }

    That will probably achieve what you want , you could adjust that conditional further if you wished. You'll need to test that thoroughly using real mobile devices , DEV tools mobile simulation won't respond to that.

    Personally , I'm not keen on using wp_is_mobile on the front end , it literally targets any device considered as 'Mobile' , tablets in any orientation for example.

    Using display: none; in CSS is the most common method

    April 26, 2021 at 1:53 pm #503847
    EatDrinkDeals
    Participant

    Your remove_action code suggestion appears to work, thank you.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

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