Title: Child Theme &#8211; Adding a &quot;Header&quot; Widget Area
Last modified: August 21, 2016

---

# Child Theme – Adding a "Header" Widget Area

 *  Resolved [jbush82](https://wordpress.org/support/users/jbush82/)
 * (@jbush82)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/)
 * I’m creating a child theme of Customizr and with it, a plugin that enables a 
   persistant fasebook based login / logoff. I’d like to have the login / logoff
   content be displayed at the top of the Customizr theme and I think the right 
   way to do this is create a child theme with a new “header” area, in addition 
   to “right sidebar”, “left sidebar”, “footer widget area one”, “footer widget 
   area two”, and three “footer widget area three”.
 * My problem is that I’m not exactly sure how to do this given it is my first go
   at it. I found the content areas within the Customizr theme (class-header-header_main.
   php), but I’d rather not replicate that file and modify the one section I want.
   As such, I’m thinking it maybe easier to create a new widget area and somehow
   point it to the right location.
 * Thoughts?

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/page/2/?output_format=md)

 *  [ElectricFeet](https://wordpress.org/support/users/electricfeet/)
 * (@electricfeet)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471166)
 * You’ve pre-empted my next snippet 🙂
 * <p>To define a new widget, add the following code to your functions.php file 
   in your child theme:</p>
 *     ```
       // Add a widget.
       if (function_exists('register_sidebar')) {
       	register_sidebar(array(
       	'name' => 'Extra Widget Before Header',
       	'id' => 'extra-widget',
       	'description' => 'Extra Widget Before Header',
       	'before_widget' => '<div id="%1$s" class="widget %2$s">',
       	'after_widget' => '</div>',
       	'before_title' => '<h2>',
       	'after_title' => '</h2>'
       	));
       }
       ```
   
 * <p>You then need to hook your widget to the beginning of the header. Add the 
   following code below the code above:</p>
 *     ```
       // Place the widget before the header
       add_filter ('__before_header', 'add_my_widget');
       function add_my_widget() {
       	if (function_exists('dynamic_sidebar')) {
       	dynamic_sidebar('Extra Widget Before Header');
       	}
       }
       ```
   
 * <p>That’s it! When you go to Appearance > Widgets, you’ll find your widget there,
   ready to be filled with whatever you want.</p>
 * You will then need to style it, of course.
 *  Thread Starter [jbush82](https://wordpress.org/support/users/jbush82/)
 * (@jbush82)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471173)
 * Perfect, exactly what I was looking for.
 * Thanks!
 *  Thread Starter [jbush82](https://wordpress.org/support/users/jbush82/)
 * (@jbush82)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471228)
 * Just wanted to give a quick update on this… after some further thinking, I decided
   to change the location of the widget (at least for my purposes). Instead of placing
   it before the entire header, I placed it after the navbar. I did this by changing“
   __before_header” to “__after_navbar”… I also played around with “before_navbar”(
   strange that this wouldn’t have the preceding __).
 * The second part of the code looks like this for placing it after the navbar but
   within the header:
 *     ```
       // Place the widget before the header
       	add_filter ('__after_navbar', 'add_my_widget');
       	function add_my_widget() {
       		if (function_exists('dynamic_sidebar')) {
       		dynamic_sidebar('Extra Widget Before Header');
       		}
       	}
       ```
   
 * The second part of the code looks like this for placing it before the navbar 
   but within the header:
 *     ```
       // Place the widget before the header
       	add_filter ('before_navbar', 'add_my_widget');
       	function add_my_widget() {
       		if (function_exists('dynamic_sidebar')) {
       		dynamic_sidebar('Extra Widget Before Header');
       		}
       	}
       ```
   
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471399)
 * [@electric](https://wordpress.org/support/users/electric/) Feet … or if you know
   where to point me, please do. 🙂
 * How does one go about “‘styling’ it, of course” … what is the next step?
 * I want to be able to do what was done at this website … [http://rvbusiness.com](http://rvbusiness.com)…
   where they put scrolling ad banners above the header, is that what this will 
   allow me to do?
 * Also, if you need to see what those lines of code above are doing, see it at …
   [http://the-rv-life.com](http://the-rv-life.com) … it is, as you all say, ‘un-
   styled’.
 * When complete will this give me a ‘widget’ drag & drop in the usual widget area?
 * Also, my Customizr Child Theme did not have a functions.php file, so I made the
   file and put the code in this functions.php file.
 * Thanks much,
    B
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471400)
 * B, you have an error in your functions.php. Probably you closed the php tag (`?
   >`) before
    ‘// Add a widget’
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471401)
 * DZ … you’ve got an amazing eye … I will repeat with care … thanks so much. B
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471402)
 * DZ … I repeated the process … I did a strict copy/paste of the code placed above
   in the string, er support thread.
 * Now look see and advise.
 * B
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471403)
 * now seems you have closed it before:
    ‘// Place the widget before the header’
   can you paste your functions.php code in pastebin: [http://pastebin.com/](http://pastebin.com/)
   and then give me the link?
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471404)
 * DZ,
 * Ok, here you go …
 * Pastebin: [http://pastebin.com/FQWF26J4](http://pastebin.com/FQWF26J4)
    Website:
   [http://the-rv-life.com/](http://the-rv-life.com/)
 * Thanks 🙂
    B
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471405)
 * This is all your child-theme functions.php?
 * So I was wrong, you didn’t close the php closing tag before the actual end, you
   never opened it
    But why you have the code 2 times, and what happend to the widget
   area declaration ????? Should be:
 *     ```
       <?php
       // Add a widget.
       if (function_exists('register_sidebar')) {
       	register_sidebar(array(
       	'name' => 'Extra Widget Before Header',
       	'id' => 'extra-widget',
       	'description' => 'Extra Widget Before Header',
       	'before_widget' => '<div id="%1$s" class="widget %2$s">',
       	'after_widget' => '</div>',
       	'before_title' => '<h2>',
       	'after_title' => '</h2>'
       	));
       }
         // Place the widget before the header
                   add_filter ('before_navbar', 'add_my_widget');
                   function add_my_widget() {
                           if (function_exists('dynamic_sidebar')) {
                           dynamic_sidebar('Extra Widget Before Header');
                           }
                   }
       ```
   
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471406)
 * DZ,
 * Hey, I did a strict copy/paste of what was in this thread, as instructed to do
   above.
 * The instructions said to put the second set of code in, so I followed the instructions.
 * Now I will follow your instructions, to the letter, because I cannot operate 
   with full knowledge on this stuff, just yet.
 * So, your help, I’d be lost without it.
 * Thx, 🙂
    B
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471407)
 * But you missed the first part, or better you deleted it, and you don’t have to
   use both hook “__after_navbar” and “before_navbar” you have to chose one of them,
   if you don’t want that are to be printed twice.
    Also sorry, I don’t think “before_navbar”
   exists, try `__before_navbar`, but where do you want to place it???
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471408)
 * DZ,
 * YIPPEEEE … and viola, there’s a new widget, so cool, oh boy, thank you, thank
   you, thank you.
 * There is now a Widget in the usual widget area. Ok, now how do I put stuff in
   there?
 * I cannot put arbitrary words in that box, like you can with a text widget. So,
   how does this widget work?
 * Thx! 🙂
    B
 *  [B](https://wordpress.org/support/users/logicintl/)
 * (@logicintl)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471409)
 * DZ,
 * I copy/pasted exactly what you put up above.
 * Has something now changed?
 * Would you please re-paste the bunch of code and I will re-copy/paste whatever
   you tell me to copy/paste.
 * I have no idea what the pieces/parts of the code mean as yet, I am learning bits
   and bits as I go along. I don’t know what goes where or why.
 * B
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/#post-4471410)
 * Don’t get what you mean B.
    You haven’t create a widget, but a widget area, you
   should see it in Widgets, named ‘Extra Widget Before Header’

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/page/2/?output_format=md)

The topic ‘Child Theme – Adding a "Header" Widget Area’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

## Tags

 * [header](https://wordpress.org/support/topic-tag/header/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 22 replies
 * 7 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/child-theme-adding-a-header-widget-area/page/2/#post-4471419)
 * Status: resolved