How to create widget sidebar in wordpress


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;


Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.