Community Forums › Forums › Archived Forums › General Discussion › Add Widget Area to Genesis Child theme homepage
Tagged: child theme, genesis, registering widget area, widget
- This topic has 6 replies, 4 voices, and was last updated 9 years, 1 month ago by zamanwaz.
-
AuthorPosts
-
March 3, 2015 at 1:16 pm #143087bibliofilleMember
Hello! I created a child theme for the main Genesis framework, and I'm trying to use the Genesis Responsive Slider just below the nav menu. I know I need to register a new widget area to do this, but I seem to be having trouble. I've read a few tutorials and posts in this forum, and I understand the concepts, but still seem to be having trouble executing.
I added the following code to the functions.php file in my child theme, and I get a blank white screen once I refresh. It then goes back to normal once I remove the code. Obviously, there is an issue with the code, but I can't figure out what it is.
`//*Register after header widget area
genesis_register_sidebar( array(
'id' => 'home-slider',
'name' => _( 'Home Slider'),
'description' => _('This is a widget area that can be placed after the header')
));//* Add the slider to the homepage
add_action('genesis_before_content_sidebar_wrap','nabm_add_widget');
function nabm_add_widget(){
if (is_home())
genesis_widget_area('home-slider', array(
'before' => '<div id="home-slider">',
));
}Any help would be much appreciated!
March 3, 2015 at 2:18 pm #143100Victor FontModeratorThe register widget code is missing the theme name:
//* Register widget areas genesis_register_sidebar( array( 'id' => 'home-slider', 'name' => __( 'Home - Slider', 'theme-name' ), 'description' => __( 'This is a widget area that can be placed after the header.', 'theme-name' ), ) );
To add the slider to the home page, you should edit your theme's front-page.php file. This code should be added to the page before the genesis() call:
add_action( 'genesis_meta', 'my_home_meta' ); function my_home_meta() { if ( is_active_sidebar( 'home-slider' ) ) { //* Add home slider widgets add_action( 'genesis_loop', 'my_home_slider_widget' ); } } function my_home_slider_widget { genesis_widget_area( 'home-slider', array( 'before' => '<div class="home-slider widget-area">', 'after' => '</div>', ) ); }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 3, 2015 at 2:26 pm #143102bibliofilleMemberWhat if my theme doesn't have a front-page.php file? Should I create one?
I'm using a basic genesis child theme that I created. Right now it just has a functions.php and style.css file.
March 3, 2015 at 3:02 pm #143106WhiteleyDesignsMemberYou could certainly create a font-page.php file, or create a different page template and set a static home page to that page and it would act the same way.
Another way to show the sidebar directly on a page template would be something like this:
<?php dynamic_sidebar( 'home-slider' ); ?>
Matt Whiteley – WhiteleyDesigns, GitHub
Designing, Developing & Creating with WordPressMarch 3, 2015 at 3:16 pm #143109bibliofilleMemberThanks for the help! I'm still wondering what I'm doing wrong. I added the theme name, but I still end up with a blank screen when I try to register and display the widget.
I'm adding the code to the bottom of the functions.php file in my child theme.
March 3, 2015 at 9:01 pm #143126Victor FontModeratorBecause your child theme only has a functions and style sheet, the page templates you are using are the default Genesis Framework pages. You have to create the front-page.php file for the child theme. Registering the widget allows it to appear in the admin widget area. You can add content to it, but unless you create a front-page for your theme as I explained above, you have nothing on which to display the new widget. The default Genesis template won't work for you.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 20, 2015 at 1:45 am #145000zamanwazMember@WhiteleyDesigns
The
<?php dynamic_sidebar( 'home-slider' ); ?>
is working. Thank you for the code. But is it possible to place it within div so that styling can be done through css?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.