Community Forums › Forums › Archived Forums › Design Tips and Tricks › Making Unique Sidebar for Home Page on Metro Theme – does not wrap?
Tagged: home page, Metro theme., Sidebar
- This topic has 3 replies, 2 voices, and was last updated 9 years, 1 month ago by StacyN.
-
AuthorPosts
-
October 29, 2015 at 1:52 pm #169551StacyNParticipant
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 #170524ChristophMemberHi,
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
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.
November 9, 2015 at 8:01 am #170556StacyNParticipantI 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 #170560StacyNParticipantI 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).
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.