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 Professional Support for Your Website Problems?

Whether you're facing website issues or struggling with code implementation, our team is here to assist. Hire us to get your website back on track.

Hire Us