Community Forums › Forums › Design Tips and Tricks › Add widget to home page – Metric theme
This topic contains 14 replies, has 3 voices, and was last updated by anitac 2 months, 1 week ago.
-
AuthorPosts
-
March 4, 2013 at 3:02 pm #24121
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 #24128You can use the Visual Hook Guide to select the location that you want – http://genesistutorials.com/visual-hook-guide/.
Twitter Handles: @thecre8tivediva | Website: Cre8tiveDiva.com | LinkedIn Group: http://goo.gl/nNe1m
Why Not Take The Challenge! – Help us answer some of the unanswered postsMarch 4, 2013 at 3:43 pm #24131Paste 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.
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.March 4, 2013 at 3:44 pm #24132Hi, 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 #24135Hi 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 #24136Here’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; }
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.March 4, 2013 at 4:04 pm #24138Thanks, 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 #24146Yes 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.
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.March 4, 2013 at 4:47 pm #24148OK, 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 #24158I was able to get this coded for you. I had Metric installed. I will post it down below.
Twitter Handles: @thecre8tivediva | Website: Cre8tiveDiva.com | LinkedIn Group: http://goo.gl/nNe1m
Why Not Take The Challenge! – Help us answer some of the unanswered postsMarch 4, 2013 at 5:12 pm #24164This reply has been marked as private.
Twitter Handles: @thecre8tivediva | Website: Cre8tiveDiva.com | LinkedIn Group: http://goo.gl/nNe1m
Why Not Take The Challenge! – Help us answer some of the unanswered postsMarch 4, 2013 at 5:23 pm #24171Just emailed your info@ address – thanks v much
March 4, 2013 at 5:28 pm #24174I sent them! Let me know how it turns out.
Twitter Handles: @thecre8tivediva | Website: Cre8tiveDiva.com | LinkedIn Group: http://goo.gl/nNe1m
Why Not Take The Challenge! – Help us answer some of the unanswered postsMarch 4, 2013 at 5:42 pm #24190Worked 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 #24515@Stefan, it looks great! Glad I could help.
Twitter Handles: @thecre8tivediva | Website: Cre8tiveDiva.com | LinkedIn Group: http://goo.gl/nNe1m
Why Not Take The Challenge! – Help us answer some of the unanswered posts -
AuthorPosts
The topic ‘Add widget to home page – Metric theme’ is closed to new replies.