Adding/registering new widget area- not seen

Community Forums Forums Design Tips and Tricks Adding/registering new widget area- not seen

This topic is: resolved

This topic contains 12 replies, has 3 voices, and was last updated by  David Chu 5 months, 2 weeks ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #112725

    korg007
    Member
    Post count: 37

    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,
    G

    #112732

    AC
    Blocked
    Post count: 7712

    Did you add the CSS to the style.css?

    #112733

    David Chu
    Participant
    Post count: 1426

    Hi,
    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

    #112735

    korg007
    Member
    Post count: 37

    Thanks 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.

    #112745

    David Chu
    Participant
    Post count: 1426

    Those 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

    #112752

    korg007
    Member
    Post count: 37

    Thanks 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.
    Cheers

    #112844

    David Chu
    Participant
    Post count: 1426

    You’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

    #112846

    korg007
    Member
    Post count: 37

    Thanks. 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,
    G

    #112852

    David Chu
    Participant
    Post count: 1426

    G,
    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

    #112854

    korg007
    Member
    Post count: 37

    Thanks 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)

    #112887

    David Chu
    Participant
    Post count: 1426

    Ha 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

    #112894

    korg007
    Member
    Post count: 37

    I’ve had a quick look and those look fantastic!
    Have a good one!
    Once again… Thanks Dave!
    G

    #112895

    David Chu
    Participant
    Post count: 1426

    G,
    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

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Adding/registering new widget area- not seen’ is closed to new replies.