Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding/registering new widget area- not seen
Tagged: enterprise widget regiter
- This topic has 12 replies, 3 voices, and was last updated 9 years, 9 months ago by David Chu.
-
AuthorPosts
-
July 2, 2014 at 3:01 pm #112725korg007Member
HI folks,
I'm using the Enterprise Pro theme and need to add a new widget area below home-top.
I'm having some challenges. Here's what I've done:1. in functions.php, I registered the new widget like this
genesis_register_sidebar( array( 'id' => 'home-intro', 'name' => __( 'Home - Intro', 'enterprise' ), 'description' => __( 'This is the intro section, below the homoe-top top section of the homepage.', 'enterprise' ), ) );
2. in front-page.php I added this:
function enterprise_home_intro_widgets() { genesis_widget_area( 'home-intro', array( 'before' => '<div class="home-intro widget-area"><div class="wrap">', 'after' => '</div></div>', ) ); }
I do see the new widget in the dashboard's widget area. I add a search and text widget plugin but nothing changes at all on my home page.
What am I missing?
Cheers,
GJuly 2, 2014 at 4:10 pm #112732AnitaKeymasterDid you add the CSS to the style.css?
Love coffee, chocolate and my Bella!
July 2, 2014 at 4:12 pm #112733David ChuParticipantHi,
You've got nice functions for building the widget and surrounding it with stuff. Now you actually need to invoke it. 馃檪 You'll want this line somewhere in there.dynamic_sidebar( 'home-intro' );
You may get unpredictable results depending on where you put it in the template. That's why I tend to use hooks to place it surgically instead of plopping it in the template. But your way can work just fine.
Dave
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
July 2, 2014 at 4:42 pm #112735korg007MemberThanks to you both.
David, you were on the right track. I was missing this in front-page.php://* Add home intro widgets add_action( 'genesis_loop', 'enterprise_home_intro_widgets' );
Here's something odd though. Originally, I had
//* Add home intro widgets add_action( 'genesis_after_header', 'enterprise_home_intro_widgets' );
But this did nothing. If someone could explain why changing genesis_after_header to genesis_loop did the trick, I would learn something 馃檪
@David, how do you use "hooks" to do something like this ? If you just provide pointers, I should be able to figure the rest.
July 2, 2014 at 6:56 pm #112745David ChuParticipantThose are hooks that you're using. I'd suggest reading the documentation that is in the Studiopress area where you download your themes. You can also use the Genesis Visual Hooks Guide to see where they are. Or you can always use templates with no hooks, it's just a different coding style.
And in fact, I had forgotten that genesis_widget_area is simply a Genesis wrapper for the standard WP command I gave you to show the sidebar.
Your code works either from functions.php or in a template, so something's not right on your setup. Your front-page.php could be borked. You need to make sure the last line in it is
genesis();
Also, your function definition of the sidebar ("register") must come before you try to invoke it with the genesis_widget_area stuff. Obviously you'll need to assign a Page as your static homepage to activate front-page.php. And lastly, have a widget in that new sidebar or you ain't gonna get nothin'. 馃檪
I would suggest Googling stuff about Genesis custom templates, and you'll get the idea.
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
July 2, 2014 at 7:44 pm #112752korg007MemberThanks David,
I'll do some digging for the doc. Thanks for the link to the visual hooks.
I'm still baffled as to why using 'genesis_after_header' did note generate any output at all.
I'm assuming you're allowed to have two actions using the same hook.
CheersJuly 3, 2014 at 7:14 am #112844David ChuParticipantYou're welcome. Yes, you can do more than one action with a hook. For instance, if you do one after the other without any priority, they will just appear in the order that you did them.
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
July 3, 2014 at 7:20 am #112846korg007MemberThanks. Than it's a mystery as to why my new widget with hook genesis_after_header was not appearing.
Oh well... found a workaround.
Cheers,
GJuly 3, 2014 at 8:05 am #112852David ChuParticipantG,
One last fun factoid that may be of use... since Genesis 2 came out, many hooks require careful use of priority. This may not only determine where your output will appear, but whether it will appear at all.For instance, I was just working with an old Genesis landing page template, and found that to remove the Secondary nav, I needed to remove the priority number, which had been 15.
In other cases, having a priority number is necessary. I wrote an article about some of the Genesis 2 hooks. The priority needs constantly shift, and unfortunately, one must find them by trial and error, because they are barely documented, if at all.
So it's possible you ran into this, but hard to say for sure. Another "gotcha" you may find occasionally when coding in templates is that sometimes a variable might be out of scope and require a global variable (doh!) or at least one of the WP functions that can grab something without explicitly using "global".
Cheers, D
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
July 3, 2014 at 8:15 am #112854korg007MemberThanks Dave. Very likely this is what occurred as all was correctly in its place.
Thanks again!
I mostly use Joomla for my web dev. Which online resource would you recommend for me to learn the finer details of Genesis? (sometimes, the creator's site is not the best option)July 3, 2014 at 11:44 am #112887David ChuParticipantHa ha, good point.
You have developer chops so you won't need the "how to install WP" type stuff. 馃檪 I'm pretty much all self-taught, but there are good sources out there.Sridhar has a lot of cool tuts.
http://sridharkatakam.com/Bill Erickson's stuff is very good.
http://www.billerickson.net/blog/Another one:
http://wpsites.net/blog/I go to the WordPress Codex a lot, and that's an important antidote to only looking at Genesis stuff. And they have this new thing, which looks promising: http://developer.wordpress.org/reference/
Dave
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
July 3, 2014 at 12:28 pm #112894korg007MemberI've had a quick look and those look fantastic!
Have a good one!
Once again... Thanks Dave!
GJuly 3, 2014 at 12:43 pm #112895David ChuParticipantG,
YW! Enjoy the holiday if you celebrate it (or even if you don't).I'll be pumping out some new stuff quite soon myself.
TTYL,
Dave
Dave Chu 路 Custom WordPress Developer – likes collaborating with Designers
-
AuthorPosts
- The topic ‘Adding/registering new widget area- not seen’ is closed to new replies.