• 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

Making Unique Sidebar for Home Page on Metro Theme – does not wrap?

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 › Making Unique Sidebar for Home Page on Metro Theme – does not wrap?

This topic is: not resolved

Tagged: home page, Metro theme., Sidebar

  • This topic has 3 replies, 2 voices, and was last updated 7 years, 4 months ago by StacyN.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 29, 2015 at 1:52 pm #169551
    StacyN
    Participant

    I have managed to successfully register a sidebar (called the Home Side - home-side ) that I created which I am intending to display on the HOME page only. In other words - I wish the usual Primary Sidebar to not show up on the Home page, but rather display a unique one for that instance only.

    Instead of showing up as a sidebar, it's showing up BENEATH my responsive slider area (which is stored in the HOME-TOP widget area).

    So, I am so very close, but I can't seem to understand how to get it to wrap correctly? Or is the fact there are also other home widget areas (such as home-middle-left, home-middle-right, etc.) make it so they do not wrap correctly?

    This is the code I've placed in my front-page.php file:

    <?php
    /**
    * This file adds the Home Page to the Metro Pro Child Theme.
    *
    * @author StudioPress
    * @package Metro Pro
    * @subpackage Customizations
    */

    add_action( 'genesis_meta', 'metro_home_genesis_meta' );
    /**
    * Add widget support for homepage. If no widgets active, display the default loop.
    *
    */
    function metro_home_genesis_meta() {

    if ( is_active_sidebar( 'home-top' ) || is_active_sidebar ( 'home-side' ) || is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-bottom' ) ) {

    // Force content-sidebar layout setting
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );

    // Add metro-pro-home body class
    add_filter( 'body_class', 'metro_body_class' );
    function metro_body_class( $classes ) {
    $classes[] = 'metro-pro-home';
    return $classes;
    }

    // Remove the default Genesis loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );

    // Add homepage widgets
    add_action( 'genesis_loop', 'metro_homepage_widgets' );

    }
    }

    function metro_homepage_widgets() {

    function metro_homepage_widgets() {

    genesis_widget_area( 'home-top', array(
    'before' => '<div class="home-top widget-area">',
    'after' => '</div>',
    ) );


    genesis_widget_area( 'home-side', array(
    'before' => '<div class="home-side widget-area">',
    'after' => '</div>',
    ) );

    if ( is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) ) {

    echo '<div class="home-middle">';

    genesis_widget_area( 'home-middle-left', array(
    'before' => '<div class="home-middle-left widget-area">',
    'after' => '</div>',
    ) );

    genesis_widget_area( 'home-middle-right', array(
    'before' => '<div class="home-middle-right widget-area">',
    'after' => '</div>',
    ) );

    echo '</div>';

    }

    genesis_widget_area( 'home-bottom', array(
    'before' => '<div class="home-bottom widget-area">',
    'after' => '</div>',
    ) );

    }

    genesis();

    http://rockfordmichamber.com/mobile/
    November 8, 2015 at 10:55 pm #170524
    Christoph
    Member

    Hi,

    that´s a lot of trouble just to show a different sidebar on the home page.

    It´s a lot easier to write a conditional function or use a plugin like
    https://wordpress.org/plugins/genesis-simple-sidebars/
    or
    https://wordpress.org/plugins/widget-logic/
    and there are many more plugins out there...

    If you want to continue with your code, you probably have to position the new widget area/sidebar with css.


    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    November 9, 2015 at 8:01 am #170556
    StacyN
    Participant

    I am already using Simple Sidebars for other sections throughout the website. We are trying to make their former not-mobile ready website match as closely as it formerly did: http://rockfordmichamber.com

    They want their special buttons (located on the right side of the slider) to remain in place on the HOME page only

    I also set up the former website for them using the Associate theme a couple of years ago. At that time, I managed to accomplish the very thing I'm attempting to do right now (added that sidebar alongside the slider via coding). But for some reason, I cannot seem to re-create the same sidebar setup in Metro.

    If I go the route of using the Simple Sidebars instead - then I need to find a way to have the Home page call to THAT sidebar (which I have created because I thought perhaps this would need to be my solution).

    Any suggestions are greatly appreciated.

    November 9, 2015 at 8:29 am #170560
    StacyN
    Participant

    I mean - it's apparent to me then, I need to have the front-page.php file call to a sidebar crafted just for the Home Page.

    I tried one using Simple Sidebars. That sidebar is called "home-page-sidebar" but I can't seem to figure out where to call to it.

    Then I tried manually coding a sidebar I made called "home-side" and it shows up, but UNDER the slider instead of adjacent to it. It shows up under the slider and the Primary Sidebar is still showing as well (instead of being replaced by the home-side).

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

© 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