The WordPress widgets are used to add additional functionality to your blog or site. They are standalone areas of code which can be of any type such as Search bar, text, calendar etc.
In this article, there is a step by step explanation that guides you, how to add widget area to the header in WordPress. The Widgets are usually available at sidebars of any website, but it is purely up to you that where you want to add it. It can also be added to the header or footer.
Steps to Add Widget Area to the Header in WordPress
Step 1: Firstly, from the Appearance menu , click on “Editor”.
Step 2: Then from the given Templates go to “functions.php”.
Step 3: Insert the code shown below under fuctions.php and click on “Update”.
if ( function_exists (‘register_sidebar’) )
register_sidebar( array(
‘name’ => __( ‘Header Widgets Area’, ‘twentythirteen’ ),
‘id’ => ‘sidebar-header’,
‘description’ => __( ‘Header widgets area for my child theme.’ , ‘twentythirteen’ ),
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
Step 4: Click on “header.php” below the functions.php as shown in the image below.
Step 5: Insert the code mentioned below, after that click on “Update”.
<?php dynamic_sidebar(‘Header Widgets Area’); ?>
Step 6: Header widget is now added to the widgets section, to make any changes go to “Widgets” under Appearance menu.
Step 7: You”ll see “Header Widget Area”, here you can add the widget which you want to display in the header.
Step 8: Drag the widget from Active or Inactive Widget & Drop it to the “Header Widget Area”.
Here I have added “Search” widget and then click on “Save”.
Step 9: Your widget will appear on your blog like this as shown below.
Leave a Reply