How do I style a new widget position in twentyeleven child theme (6 posts)

  1. jgold723
    Posted 3 years ago #

    I've successfully followed the instructions in: http://codex.wordpress.org/Widgetizing_Themes
    for creating a new widget position.

    But now I want to style it and I'm completely baffled. The function that registers the new widget:

    register_sidebar( array(
    		'name' => __( 'Home Nugget', 'twentyeleven' ),
    		'id' => 'home-nugget',
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget' => "</aside>",
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );

    [Please post code or markup snippets between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    Works, but of course it uses the standard widget styling, which I want to change. And if I change the aside class to anything else, the widget doesn't display at all.

    How do I create a unique class for this particular widget?



  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try styling on the widget id.

  3. jamesg40
    Posted 3 years ago #

    Add home-nugget to your style.css and style that

  4. Michael
    Forum Moderator
    Posted 3 years ago #

    what is the code of your new 'sidebar', i.e. where you output the dynamic_sidebar() ?

    you could use something like:

    <?php if ( is_active_sidebar( 'home-nugget' ) ) : ?>
    <div id="nugget" class="widget-area">
    <?php if ( !dynamic_sidebar( 'home-nugget' ) ) : ?>
    <?php endif; ?>
    <?php endif; ?>

    and then style for instance:

    #nugget aside {...}

  5. jamesg40
    Posted 3 years ago #

    Nice alchymyth! man, I continue to learn so much from you guys. :-)

  6. jgold723
    Posted 3 years ago #

    Thanks alchymyth -- I think that'll work!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.