You can also use widget outside the sidebar. To registering a widget area add following code in your theme’s functions.php file.
function smallenvelop_widgets_init() {
register_sidebar( array(
‘name’ => __( ‘Header Sidebar’, ‘smallenvelop’ ),
‘id’ => ‘header-sidebar’,
‘before_widget’ => ‘<div>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h1>’,
‘after_title’ => ‘</h1>’,
) );
}
add_action( ‘widgets_init’, ‘smallenvelop_widgets_init’ );
To display Widget Area add the following code to a location of your choice in your theme file. Here I am adding this code in my theme’s header.php
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘header-sidebar’) ) :
endif; ?>
I have applied it on one of my website. You can check it on reviewlog.org/