Viewing 7 replies - 1 through 7 (of 7 total)
  • 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?

    where have you defined this function:
    techild_header_widget();
    and what code is in it?

    in step(2) you could just use something like:

    <?php if ( is_active_sidebar( 'header-widget' ) ) : ?>
    <div><?php dynamic_sidebar( 'header-widget' ); ?></div>
    <?php endif; ?>

    For anyone interested:
    http://www.huurautohuren.com/twenty-eleven-child-theme-free-download/

    It’s a twenty eleven child theme with only two changes, it has sidebar support for posts and adds 4 widget area’s to the header. So you can use this one, or have a look at the code and implement it in yours.

    Hi Jan1979,
    Thanks for sharing the child theme. I added a widget on the header (below the navigation/menu) and I want to add a background image to that area. How do I do it? Do I use z-index in css?Thank you and thanks anyone who answers.

    I am using Weaver II theme. Is there a way I can add a header widget?

    Honestly speaking, I am trying to really define a simple shopping cart with a few options – example a category which has 4 choices: family, single, single family and single student. Based on each choice, a specific price shall be defined.

    Please let me know if you have suggestions.

    Thanks for your help.

    @pikpi1965

    please start you own topic

    – your problem is different as you are not even using the same theme.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add widget area to header in TwentyEleven child theme’ is closed to new replies.