1. Registering a custom widget area
To registering a widget area add following code in your theme’s functions.php file.
2. Display Widget Area
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
All done, this is how we create new widget area!
To registering a widget area add following code in your theme’s functions.php file.
function header_sidebar_widgets_init() {
register_sidebar( array(
'name' => __( 'Header Sidebar', 'header_sidebar' ),
'id' => 'header-sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h1>',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'header_sidebar_widgets_init' );
2. Display Widget Area
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; ?>
All done, this is how we create new widget area!
Friday, January 4, 2019
WooCommerce
WordPress