Community Forums › Forums › Archived Forums › Design Tips and Tricks › Agency – adding a widget area above the header
- This topic has 10 replies, 4 voices, and was last updated 11 years, 2 months ago by
weezieb.
-
AuthorPosts
-
December 9, 2013 at 10:12 am #77839
carrieoke13
ParticipantI'm trying to add a widget area above the header in the Agency theme. I've registered the widget in my functions.php file, but I'm stumped on how to actually get it into the header. I tried using Genesis Simple Hooks and putting in the before header area, but it's showing the php code instead of executing the code and showing the widget. Any ideas?
Thanks!
Also - I can't link to the site because it's not publicly visible - sorry about that :/
December 9, 2013 at 10:17 am #77841nutsandbolts
MemberIn general, you need two functions - one to register the widget area and another to tell it where it should show up. Can you paste in what you've been using?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 9, 2013 at 11:06 am #77849carrieoke13
ParticipantYes - here's what's in my functions.php for Agency:
//* Custom widget above top nav genesis_register_sidebar( array( 'id' => 'above-menu', 'name' => __( 'Above Menu', 'agency' ), 'description' => __( 'This is a widget area that can be placed above the top nav menu', 'agency' ), ) );
and here's the code I tried to use in simple hooks:
genesis_widget_area( 'above-menu', array( 'before' => '<div class="above-menu">', 'after' => '</div>',
Thank you!!
December 9, 2013 at 1:40 pm #77869Brad Dalton
ParticipantIt should look more like this in your functions file.
https://gist.github.com/cbe8a26cacbaeac6bcbc.git
December 9, 2013 at 1:41 pm #77870Brad Dalton
ParticipantIt should look more like this in your functions file.
Change the conditional tag and hook position to suit your needs
December 10, 2013 at 2:43 pm #78145carrieoke13
ParticipantThank you. I am trying to make this work but I am getting a php error.
here's what I tried:
genesis_register_sidebar( array( 'id' => 'above-menu', 'name' => __( 'Above Menu', 'agency' ), 'description' => __( 'This is a widget area that can be placed above the top nav menu', 'agency' ), ) ); add_action( 'genesis_before_header', 'above-menu' ); function your_widget() { if ( is_front_page() ) { genesis_widget_area( 'above-menu', array( 'before' => '<div class="above-menu">', 'after' => '</div>', ) ); } }
and it returned an error. it actually just needs to display on all pages. what should I change?
December 10, 2013 at 2:47 pm #78147carrieoke13
ParticipantNever mind - I found my mistake! here is what worked. thank you again!
//* Custom widget above top nav genesis_register_sidebar( array( 'id' => 'above_menu', 'name' => __( 'Above Menu', 'agency' ), 'description' => __( 'This is a widget area that can be placed above the top nav menu', 'agency' ), ) ); add_action( 'genesis_before_header', 'above_menu' ); function above_menu() { if ( is_front_page() ) { genesis_widget_area( 'above_menu', array( 'before' => '<div class="above_menu">', 'after' => '</div>', ) ); } }
December 10, 2013 at 3:17 pm #78165Brad Dalton
ParticipantPlease copy the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++ as the scroll bar can hide some code.
January 13, 2014 at 3:39 pm #85055weezieb
MemberThis post was very helpful to me except I'd like this on all pages, not just my front page. Any help on what to change is_front_page to? I can't do just is_page because then it won't work on posts. Or it didn't when I tried.
Thanks!January 13, 2014 at 4:39 pm #85065Brad Dalton
ParticipantChange this line:
if ( is_front_page() && is_active_sidebar('before-header')
To this:
if ( is_active_sidebar('before-header')
Or remove the entire line.
January 14, 2014 at 9:49 am #85152weezieb
MemberThank you so much!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.