Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add widget to home page – Metric theme
- This topic has 14 replies, 3 voices, and was last updated 11 years, 1 month ago by Anita.
-
AuthorPosts
-
March 4, 2013 at 3:02 pm #24121AnonymousInactive
Hi guys,
I'm trying to add a full width widget on the home page of the Metric theme, directly above the 3 widgets called 'Home Middle #1-3', so between the blue and white parts of the site - http://cabinetdesigner.net/.
I think I now know how to register a widget and hook it to the home page - as described here http://www.briangardner.com/home-widget-area-eleven40/ - but I'm not sure what hook to use (genesis_before_loop or another?), or where in home.php to put it.
Any help greatly appreciated.
Thanks very much,
Stefan
March 4, 2013 at 3:35 pm #24128AnitaKeymasterYou can use the Visual Hook Guide to select the location that you want - http://genesistutorials.com/visual-hook-guide/.
Love coffee, chocolate and my Bella!
March 4, 2013 at 3:43 pm #24131Brad DaltonParticipantPaste this code at the end of your child themes functions.php file rather than edit the home.php file;
Remove any code you have already added to register the widget.
March 4, 2013 at 3:44 pm #24132AnonymousInactiveHi, Anitac.
Thanks for your response. I'm still stuck though.
I cannot work out how the guide applies to a home page, particularly a position in between the various widget areas already there.
Thanks again,
Stefan
March 4, 2013 at 3:51 pm #24135AnonymousInactiveHi Brad. Thanks as well. I added the code at the bottom of the functions file, and cannot see anything any change on the home page, but it does appear at the top of posts e.g. http://cabinetdesigner.net/design-a-cabinet-under-a-roof/, which seems strange.
March 4, 2013 at 3:53 pm #24136Brad DaltonParticipantHere's the code
genesis_register_sidebar( array( 'id' => 'home-custom', 'name' => __( 'Home Slider', 'metric' ), 'description' => __( 'This is the custom widget area for your homepage.', 'metric' ), ) ); add_action( 'genesis_before_content_sidebar_wrap', 'child_before_content'); function child_before_content() { if ( is_home() ) { echo '<div id="home-custom">'; dynamic_sidebar( 'home-custom' ); echo '</div><!-- end #home-custom -->'; } }
Modify the sample CSS below or add more declarations:
.home-custom { background: #f2f2f2; padding: 5px; border: 5px solid #D4D0C8; }
March 4, 2013 at 4:04 pm #24138AnonymousInactiveThanks, Brad. I've added that, and put a text widget in that new widget area with 'text to follow' as the content...but I still cannot see it for some reason.
March 4, 2013 at 4:34 pm #24146Brad DaltonParticipantYes you're right Stefan.
It doesn't work on that theme because the home.php file is coded differently to the newer themes so you might need to custom code the home.php file as the genesis_hooks won't output the widget area exactly where you want using a custom function.
I've tried using different hooks but it still doesn't work.
My code uses a conditional tag is_home so it only displays on the home page.
March 4, 2013 at 4:47 pm #24148AnonymousInactiveOK, thanks again. I'll see if I can see how the other widgets have been generated, and replicate one of those. Wish me luck!
March 4, 2013 at 5:07 pm #24158AnitaKeymasterI was able to get this coded for you. I had Metric installed. I will post it down below.
Love coffee, chocolate and my Bella!
March 4, 2013 at 5:12 pm #24164AnitaKeymasterThis reply has been marked as private.March 4, 2013 at 5:23 pm #24171AnonymousInactiveJust emailed your info@ address - thanks v much
March 4, 2013 at 5:28 pm #24174AnitaKeymasterI sent them! Let me know how it turns out.
Love coffee, chocolate and my Bella!
March 4, 2013 at 5:42 pm #24190AnonymousInactiveWorked PERFECTLY! It's on a test site at the moment, but will be on the one I mentioned above soon.
Thank you very much!!!!
(I can go to bed happy now, getting late here in the UK)
March 6, 2013 at 5:36 am #24515AnitaKeymaster@Stefan, it looks great! Glad I could help.
Love coffee, chocolate and my Bella!
-
AuthorPosts
- The topic ‘Add widget to home page – Metric theme’ is closed to new replies.