Community Forums › Forums › Archived Forums › Design Tips and Tricks › Placing a footer banner above footer widgets, how is this?
- This topic has 5 replies, 2 voices, and was last updated 11 years, 1 month ago by Brad Dalton.
-
AuthorPosts
-
October 6, 2013 at 11:17 am #65564RustyMember
Hi Folks,
I want to place a full width "footer banner" after the .site-inner, and before .site-footer ..
I will use this area to create a widget area that will contain a horizontal optin form.
My first attempt was to use 'genesis_after_content_sidebar_wrap', but that sent the output just under the right sidebar, still within .site-inner.
Finally, I came up with the following snippet. It what I want it, however I don't know if this is a "best practice".
Would some kind, smart person let me know if there is 'better' way to do this within the Genesis framework.
Here is my snippet of code: (link to github gist here: https://gist.github.com/rustyeddy/6856424).
/* * Use this footer widget to place another nav bar area */ remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' ); add_action( 'genesis_before_footer', 'lpo_do_footer_banner' ); function lpo_do_footer_banner() { echo "<div class='lpo-footer-banner'>"; echo "<div class='wrap'>"; echo '<h1>This is my banner</h1>'; echo "</div><!-- wrap -->"; echo "</div><!-- lpo-footer-banner-wrap -->"; genesis_footer_widget_areas(); }
Rusty Eddy
October 7, 2013 at 2:32 am #65617Brad DaltonParticipantHere's the correct code for adding a widget area before the footer in Genesis
You can add any remove actions as well if you need to.
You can also reposition the footer widgets or footer if needed http://dreamwhisperdesigns.com/genesis-tutorials/relocate-genesis-footer-widgets/
October 8, 2013 at 9:32 am #65844RustyMemberThanks for the response Brad!
My main objective wasn't so much to add the sidebar widget (I've done that plenty of times). It was to figure out how to get my new widget area above the footer widget area. So I tried to keep the code in the original post simple without the distraction of the sidebar widget code.
If I use the code above it will place my "footer banner" in the incorrect order, under the footer widgets, before the footer.
So, the only way I have been able to figure out how to get the banner above the widget area is to remove the "genesis_footer_widget_areas()', create my own hook, and then call the "genesis_footer_widget_areas()" after printing the banner in the new hook.
It works, so I guess it'll be fine.
Any way, here is the final code:
/* * ------------------------------------------------------------------------- * Create the widget area to span the width of the site above the * footer. */ $lpo_footer_banner = array( 'id' => 'footer-banner', 'name' => __( 'Footer Banner', 'Lake Park' ), 'description' => __( 'Footer Banner above widgets', 'Lake Park' )); genesis_register_sidebar( $lpo_footer_banner ); /* * Remove the existing genesis before footer hook because we are going * to replace it with our own. Otherwise we'll end up with our banner * below the footer widet area. * * We'll then call the footer widget hook after we summons our footer * banner. */ remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' ); add_action( 'genesis_before_footer', 'lpo_do_footer_banner' ); /* * Just do it. */ function lpo_do_footer_banner() { /* * Draw the footer banner if we have placed any widgets. */ if ( is_active_sidebar( 'footer-banner' ) ) { $do_widget = array ( 'before' => "<div class='lpo-footer-banner'><div class='wrap'>", 'after' => "</div><!-- wrap --></div><!-- lpo-footer-banner -->", ); genesis_widget_area( 'footer-banner', $do_widget ); } /* * Now draw the footer widgets */ genesis_footer_widget_areas(); }
The github link if anybody is interested: https://gist.github.com/rustyeddy/6856424
Rusty Eddy
October 8, 2013 at 7:00 pm #65904Brad DaltonParticipantNot if you add a 3rd parameter for positioning priority below 10.
Just tested the code and it displays the content before the footer.
October 10, 2013 at 2:17 am #66088RustyMemberThank you Brad. That is a much better (and more elegant) solution thanI came up with.
I do now remember wondering if there was a way to prioritize the order in which elements are displayed...
Rusty Eddy
October 10, 2013 at 4:31 am #66097Brad DaltonParticipantNo worries. Pretty simple solution which is used a lot with the new loop hooks as well.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.