Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding a Widget in Genesis Sample Theme
Tagged: custom widget
- This topic has 8 replies, 4 voices, and was last updated 9 years, 5 months ago by Annaedv.
-
AuthorPosts
-
February 6, 2014 at 10:10 pm #89066garyjalbertMember
I am creating a custom website using the Genesis Sample as the child theme, and would like to add a widget to display a slider in the top center of the home page (i.e. just below the header). I am capable of registering the widget, but for some reason I can't get the widget to work. Does anyone know the proper code to make this happen? Once again, I am looking to place a Genesis Responsive Slider just below the header, or just above the entry content.
Thank you!
February 6, 2014 at 10:20 pm #89069nutsandboltsMemberOnce you register the widget, you also need to include a function to tell the widget where to display. In this case, you'd do something like this (but replacing "home-slider" with whatever you named your widget area):
//* Add the page widget in the content - HTML5 add_action( 'genesis_before_content_sidebar_wrap', 'nabm_add_widget' ); function nabm_add_add_widget() { if ( is_home() ) genesis_widget_area( 'home-slider', array( 'before' => '<div id="home-slider">', ) ); }
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+February 6, 2014 at 10:40 pm #89076garyjalbertMemberAndrea,
Thank you for the quick reply! So that I am clear, these are both supposed to go in the functions.php file, correct? That's where I placed the registration, and it shows up in my widget display. Anyway, I did plug in your code above, but it's still not showing up? Below is my registration code and the code you provided above. Please let me know if you see a mistake or not. If not, am I supposed to place something in the style.css file?
//* Register after header widget area
genesis_register_sidebar( array(
'id' => 'after-header',
'name' => __( 'After Header', 'themename' ),
'description' => __( 'This is a widget area that can be placed after the header', 'themename' ),
) );//* Add the page widget in the content - HTML5
add_action( 'genesis_before_content_sidebar_wrap', 'nabm_add_widget' );
function nabm_add_add_widget() {
if ( is_home() )
genesis_widget_area( 'after-header', array(
'before' => '<div id="after-header">',
) );
}Thank you again for your help!
Gary
February 6, 2014 at 10:42 pm #89078nutsandboltsMemberYes, that's correct. Both of those should go in functions.php. And I just noticed it's my fault because I have a typo in the function. Try this one:
//* 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">', ) ); }
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+February 6, 2014 at 10:51 pm #89081garyjalbertMemberSo is this how it should read? If so, it still doesn't appear to be working. I've placed a text widget inside with "Test" inside, and it's not showing up on my home page.
//* Register after header widget area
genesis_register_sidebar( array(
'id' => 'after-header',
'name' => __( 'After Header', 'themename' ),
'description' => __( 'This is a widget area that can be placed after the header', 'themename' ),
) );//* 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( 'after-header', array(
'before' => '<div id="after-header">',
) );
}February 6, 2014 at 10:55 pm #89086nutsandboltsMemberThat's exactly what it should be, but I'm wondering if you've lost some formatting in copying/pasting from the forum. I'd be glad to log in and take a look if you're comfortable with that. If so, you can email me at [email protected]
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+October 17, 2014 at 3:26 am #128114AnnaedvParticipantHello. I´m trying to do the same as you in Genesis Sample.
1. I try to follow the templates in Studiopress but Genesis Sample does not have a home.php and then I only see the widget in admin. Nothing appears live.
2. I try to past in your code in functions.php but my pages crasches.
What to do?
/AnnaOctober 17, 2014 at 3:53 am #128117Brad DaltonParticipantRemove the code and try this http://wpsites.net/web-design/widget-genesis/
October 17, 2014 at 5:13 am #128120AnnaedvParticipantJabbadabbadoooo! It works! Thank you!
Anna -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.