How to Register a Widget Area In the WordPress with the help of function.

We often need widgets in wordpress. Sometime its already in the wordpress or comes with themes. But sometime we need to create widget. Here is the function which is useful to create a widget without customize any wordpress core file.

function my_custom_widget_area() {
 register_sidebar( array(
 'name' => 'Custom sidebar',
 'id' => 'custom_sidebar',
 'before_widget' => '<div>',
 'after_widget' => '</div>',
 'before_title' => '<h2>',
 'after_title' => '</h2>',
 ) );
add_action( 'widgets_init', 'my_custom_widget_area' );

Copy this code and add it in the function file of your theme. We can also use plugins but too much plugins can slow the website.

How to call the widget in template Area?

Share With Friends

Speak Your Mind


Time limit is exhausted. Please reload CAPTCHA.