Community Forums › Forums › Archived Forums › Design Tips and Tricks › Widget area not appearing
- This topic has 1 reply, 2 voices, and was last updated 8 years, 5 months ago by Victor Font.
-
AuthorPosts
-
October 12, 2015 at 2:34 am #167898TmgaleMember
Hi all,
I am trying to register & hook a widget area into genesis_before_footer.
I have successfully registered the widget areas as they appear in the backend, but I can't seem to hook them in to get them show up in my desired location.
I have looked through my code, but I am having trouble figuring out why. Does anyone have any ideas??
//newsletter bar //Add in new Widget areas add_action( 'widgets_init', 'hello_bar_extra_widgets2' ); function hello_bar_extra_widgets2() { genesis_register_sidebar( array( 'id' => 'preheaderleft2', 'name' => __( 'preHeaderLeft2', 'themename' ), 'description' => __( 'This is the preheader Left area2', 'themename' ), 'before_widget' => '<div class="first one-half preheaderleft2">', 'after_widget' => '</div>', ) ); genesis_register_sidebar( array( 'id' => 'preheaderright2', 'name' => __( 'preHeaderRight2', 'themename' ), 'before_widget' => '<div class="one-si preheaderright2">', 'description' => __( 'This is the preheader Left area', 'themename' ), 'after_widget' => '</div>', ) ); } //Position the preHeader Area add_action('genesis_before_footer','hello_bar_preheader_widget2'); function hello_bar_preheader_widget2() { echo '<div class="preheadercontainer2 hello-bar "><div class="wrap">'; genesis_widget_area ('preheaderleft2', array( 'before' => '<div class="preheaderleftcontainer">', 'after' => '</div>',)); genesis_widget_area ('preheaderright2', array( 'before' => '<div class="preheaderrightcontainer2">', 'after' => '</div>',)); echo '</div></div>'; }
Thanks.
Tom
October 12, 2015 at 2:28 pm #167952Victor FontModeratorThe HTML that you're generating is a little wonky. If you write out the code the way you've got everything declared it looks like this:
<div class="preheadercontainer2 hello-bar "> <div class="wrap"> <div class="preheaderleftcontainer"> <div class="first one-half preheaderleft2"> </div> </div> <div class="preheaderrightcontainer2"> <div class="one-si preheaderright2"> </div> </div> </div> </div>
You really don't need the before widget and after widget declaration in the genesis_register_sidebar. Adding those elements there wraps every widget in the before/after divs. So if you have more than one widget in the left area, they will all be wrapped in one-half first. You will never close the columns.
I think this is what you're trying to achieve:
//Add in new Widget areas add_action( 'widgets_init', 'hello_bar_extra_widgets2' ); function hello_bar_extra_widgets2() { genesis_register_sidebar( array( 'id' => 'preheaderleft2', 'name' => __( 'preHeaderLeft2', 'themename' ), 'description' => __( 'This is the preheader Left area2', 'themename' ), ) ); genesis_register_sidebar( array( 'id' => 'preheaderright2', 'name' => __( 'preHeaderRight2', 'themename' ), 'description' => __( 'This is the preheader Left area', 'themename' ), ) ); } //Position the preHeader Area add_action('genesis_before_footer','hello_bar_preheader_widget2'); function hello_bar_preheader_widget2() { echo '<div class="preheadercontainer2 hello-bar "><div class="wrap">'; genesis_widget_area ('preheaderleft2', array( 'before' => '<div class="preheaderleftcontainer">', 'after' => '</div>', )); genesis_widget_area ('preheaderright2', array( 'before' => '<div class="preheaderrightcontainer2">', 'after' => '</div>', )); echo '</div></div>'; }
Make sure you change themename to match the name of your theme.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet? -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.