WordPress   

Add multiple custom widget areas in WordPress

This code can used to add multiple widget areas in WordPress website. In this example I am going to add Header Ads, Footer Ads and Sidebar Ads widget areas.

Note – Please use unique id for each widget area and don’t forget to replace the textdomain with the active theme’s textdomain.

function add_multiple_widget_areas() {
	register_sidebar( array(
		'name'          => __( 'Header Ads', 'textdomain' ),
		'id'            => 'header-ads',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widgettitle">',
		'after_title'   => '</h3>',
	));
	
	register_sidebar( array(
		'name'          => __( 'Sidebar Ads', 'textdomain' ),
		'id'            => 'sidebar-ads',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widgettitle">',
		'after_title'   => '</h3>',
	));
	
	register_sidebar( array(
		'name'          => __( 'Footer Ads', 'textdomain' ),
		'id'            => 'footer-ads',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widgettitle">',
		'after_title'   => '</h3>',
	));
}
add_action( 'widgets_init', 'add_multiple_widget_areas' );
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us