ThemeShaper Forums » Thematic

Two widgets in header

(4 posts)
  • Started 3 years ago by KateFox
  • Latest reply from Chris
  • This topic is resolved

Tags:

  1. KateFox
    Member

    I'm trying to use this answer (http://themeshaper.com/forums/topic/widgets-in-the-header/) to put two widgets in my header, one on each side of the title/description. (Sorry for the double post, but nobody seems to be monitoring that original topic.)

    So far, so good - except that I'm getting the right widget below the line and can't seem to get it to move up into line. I know I'm doing something stupid and will smack myself in the forehead when you show me the error of my ways:

    Here's the CSS in style.css in my child theme:

    '#header_box {
    clear: both;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    width: 960px;
    }

    /* Moves blog name & description to the center */
    #branding {
    float: right;
    width: 400px;
    margin: 0 320px 0 0;
    padding: 50px 0 0 0;
    }

    /* Moves the new widgetized area to the left and levels it with #branding */
    #headerleft-aside {
    float: left;
    width: 190px;
    padding: 50px 0 0 0;
    margin: 0 0 0 0;
    }

    /* Moves the new widgetized area to the right and levels it with #branding */
    #headerright-aside {
    float: right;
    width: 220px;
    padding: 0 0 0 0;
    margin: 0 0 0 0;
    }

    /* This will clear the floats and keeps the access bottom line
    from jumping into the air */
    #access {
    clear: both;
    }
    '

    And here's what I added to my child theme functions.php:

    'function my_widgets_init() {
    register_sidebar(array(
    'name' => 'Header Left Aside',
    'id' => 'headerleft-aside',
    'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
    'after_widget' => "\n",
    'before_title' => "<h3 class=\"widgettitle\">",
    'after_title' => "</h3>\n",
    ));
    register_sidebar(array(
    'name' => 'Header Right Aside',
    'id' => 'headerright-aside',
    'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
    'after_widget' => "\n",
    'before_title' => "<h3 class=\"widgettitle\">",
    'after_title' => "</h3>\n",
    ));
    }
    add_action( 'init', 'my_widgets_init' );
    // adding the widget areas to your child theme header
    function my_header_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('headerleft-aside') ) {
    echo '<div id="headerleft-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('headerleft-aside');
    echo '' . "\n" . ''. "\n";
    echo '' . "\n" . '</div><!-- #headerleft-aside .aside -->'. "\n";
    echo "\n" . '</div><!-- #header-box -->'. "\n";
    }
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('headerright-aside') ) {
    echo '<div id="headerright-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('headerright-aside');
    echo '' . "\n" . ''. "\n";
    echo '' . "\n" . '</div><!-- #headerright-aside .aside -->'. "\n";
    echo "\n" . '</div><!-- #header-box -->'. "\n";
    }
    }
    add_action('thematic_header', 'my_header_widgets', 8);
    function remove_branding() {
    remove_action('thematic_header','thematic_brandingopen',1);
    }
    add_action('init', 'remove_branding');
    function my_brandingopen() { ?>
    <div id="header_box">
    <div id="branding">
    <?php }
    add_action('thematic_header','my_brandingopen',1);
    ?>'

    Posted 3 years ago #
  2. Hey,

    the right widgetized area is outside of header-box.

    Try to rearrange the actions inside thematic_header():

    my_headerboxopen()         1
    my_leftwidget()            2
    thematic_brandingopen()    3
    thematic_blogtitle()       4
    thematic_blogdescription() 5
    thematic_brandingclose()   6
    my_rightwidget()           7
    my_headerboxclose()        8
    thematic_access()          9

    header-leftaside, branding and header-rightaside will float:left

    Cheers,

    Chris

    Posted 3 years ago #
  3. KateFox
    Member

    Sorry - I've fixed the floats in the CSS, but you totally lost me with the reordering of the actions. Is this something I can do in the child theme functions.php?

    PS: I'm a content editor who is building a Thematic child theme for use on a regional community site. I often work with CSS but seldom delve deep into WordPress code files. Using Thematic has been an amazing learning experience; thank you so much for your great documentation.

    Posted 3 years ago #
  4. If you fixed the floats using CSS .. that's perfect.

    Yep .. you can do that in your child theme's functions.php .. you remove the actions using the standard priority like listed on Theme Hooks and then rearrange / add the actions with a different / new priority.

    For me this is easier than beating the CSS until it does what I want it to do ;-)

    Cheers,

    Chris

    Posted 3 years ago #

RSS feed for this topic

Reply

You must log in to post.