Wordpress widget
In the help of widget you can able to easily manage your wordpress ui structure, in this tutorial we are going to learn about How to create widget sidebar,Here is the code and explanation.
1. Create the function
function arphabet_widgets_init()
2. Register your sidebar
register_sidebar();
3. Add widget sidebar name, id
'name' => 'Home Page Conent',
'id' => 'home_right_1',
4. Add your widget to wordpress listing
add_action( 'widgets_init', 'arphabet_widgets_init' );
Final code
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home Page Conent',
'id' => 'home_right_1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4 class="rounded">',
'after_title' => '</h4>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
Use below code for add widget in your page
if ( is_active_sidebar( 'home_right_1' ) ) :
dynamic_sidebar( 'home_right_1' );
endif;