Online Forum To Support Coders With Technical Assistance - Read Write Execute

How to add new sidebar for my theme in wordpress

Ankit Agrawal
Ankit Agrawal
Published on August 11, 2015 · 1 min read

add below code in your theme function file

add_action( 'widgets_init', 'my_custom_register_sidebar' );

function my_custom_register_sidebar() {
 register_sidebar( array(
		'name' 				=> __( 'Custom Sidebar', 'theme_name' ),
		'id' 					=> 'custom_sidebar',
		'description'   	=> __( 'Description for custom sidebar', 'theme_name' ),
		'before_widget' 	=> '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  	=> '</aside>',
		'before_title'  	=> '<h1 class="widget-title">',
		'after_title'   	=> '</h1>'
	) );
}
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article How to add new custom post type in wordpress Next Article → How to read csv file in php