I am also trying to add a widget area to the header. I want it to go just above the search box. But am having problems!
So far I have…..
(1) registered the widget by adding the following to the functions.php in my child theme:
<!-- adding phone number above search box - This will register the widget area-->
<?php
register_sidebar( array(
'name' => __( 'Header Widget', 'twentyeleven-child' ),
'id' => 'header-widget',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
?>
(2) Added the following to header.php in my child theme:
<!-- adding widget to hold phone number above search box-->
<div><?php techild_header_widget(); ?></div>
just above the following lines that were already there:
<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
<?php get_search_form(); ?>
</div>
(3)Added some style in the css file of the child theme:
/* for phone number in header widget */
header#branding .widget{
position: absolute;
top: 2em;
rightright: 7.6%;
color: #c02336; font-size: 18px;
}
(4) In the admin panel, I can see the header widget area now listed in the widget areas. I drug and dropped the “text” widget over and used it to type in the text I wanted to display (which is a phone number).
But nothing is showing up on the site. (at least I didn’t get any of the dreaded fatal error messages when the page loaded) WHERE DID I GO WRONG?