• 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 enable sidebar for homepage only when home page is widgetised?

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 enable sidebar for homepage only when home page is widgetised?

This topic is: resolved

Tagged: content-sidebar, front page, front-page.php, genesis_pre_get_option_site_layout, layout

  • This topic has 7 replies, 2 voices, and was last updated 3 years, 8 months ago by BrendaGaelSmith.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • July 7, 2019 at 10:39 pm #492179
    BrendaGaelSmith
    Participant

    I would like to enable a sidebar for the home page only and have the balance of the site full width by default.

    The home page is widgetised. If full width is checked in theme settings, the sidebar does not show up on the home page. If Content, Sidebar is checked in theme settings, the full width setting has to be manually set for all other pages.

    Is it possible to enable the primary sidebar for the home page only?

    http://serendipitypatchwork.com.au/sandbox3
    July 7, 2019 at 11:36 pm #492180
    Brad Dalton
    Participant

    What you can do is add 1 line of PHP code to your child themes front-page.php file.

    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
    

    Another option is to add code to your child themes functions file which enables you to conditionally change the layout.


    Tutorials for StudioPress Themes.

    July 8, 2019 at 3:02 pm #492199
    BrendaGaelSmith
    Participant

    That snippet worked perfectly. Thank you!

    July 8, 2019 at 7:26 pm #492205
    BrendaGaelSmith
    Participant

    Actually, that snippet worked OK with the Lifestyle Pro theme but not with the Foodie Pro theme. I will have to try the conditional layout coding but that will stretch me.

    July 8, 2019 at 11:24 pm #492207
    Brad Dalton
    Participant

    I tested both solutions in the Foodie Pro themes front-page.php file and the functions.php file and both work.

    Note : When using the 2nd solution, you will need to use the is_front_page() conditional tag.


    Tutorials for StudioPress Themes.

    July 13, 2019 at 11:32 pm #492355
    BrendaGaelSmith
    Participant

    Thanks Brad.

    I set up a fresh Foodie Pro installation at http://www.serendipitypatchwork.com.au/sandbox2; changed the settings so that the static sample page is the home page and changed the layout in theme settings to full width.

    Still no joy when adding the snippet to the front-page.php file. That is to say, no sidebar re-appeared on the home page.

    As for adding conditional coding to the functions.php file, I get the beginning part and the if part but am not clear on how to string it all together without getting syntax errors. I tried all sorts of combinations. For example, the following code simply placed the sidebar on the left and not just on the home page but the blog page too.

    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );  	
    		{
    if (is_front_page()) {
    $opt = 'content-sidebar';
    return $opt;
        }
    }

    Any further guidance is welcome. Thank you.

    July 13, 2019 at 11:51 pm #492356
    Brad Dalton
    Participant

    1. I never mentioned changing any settings meaning i would leave the Reading settings as default.

    2. Please check your code because it doesn't look like the code i posted in the tutorial.


    Tutorials for StudioPress Themes.

    July 14, 2019 at 4:46 pm #492365
    BrendaGaelSmith
    Participant

    Success! These are the steps I took with the Foodie Pro theme:

    1. I went back and inserted content in the front page widgets to enable the front page.
    2. I changed the Reading settings back to default so that home page displays latest posts.
    3. I changed the site to default to full-width content via Customise>Theme Settings.
    4. I tried adding the one line snippet to the front-page.php file but it still did not work for me in either the fresh install or the work-in-progress install.
    5. I added the code below to the functions.php file and the sidebar reappeared on the home/front page of both sites
    6. add_filter( 'genesis_pre_get_option_site_layout', 'change_layout_blog_page');
      function change_layout_blog_page( $opt ) {
      if (is_front_page()  ) {
      $opt = 'content-siderbar';
      return $opt;
          }
      }

      I was confused as the tutorial link contains coding for a variety of scenarios and initially I did not associate "change_layout_blog_page" with the home page but I got there in the end. Thank you for your patience and guidance.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘How to enable sidebar for homepage only when home page is widgetised?’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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