How to Register Sidebars a Better Way in WordPress

Snippets by IsItWP

Are you looking for a way to register sidebars in WordPress? While there’s probably a plugin for this, we have created a quick code snippet that you can use to register sidebars a better way in WordPress.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

add_action( 'widgets_init', 'theme_register_sidebars' );

function theme_register_sidebars() {

	/* Register the 'sidebar #1' sidebar. */
			'id' => 'sidebar',
			'name' => __( 'Sidebar #1' ),
			'description' => __( 'Sidebar #1' ),
			'before_widget' => '',
			'after_widget' => '',
			'before_title' => '',
			'after_title' => ''
 	// Copy & Paste the "register_sidebar" code to create more sidebars. Don't forget to change the ID!

Make sure to change the sidebar’s ID in the above code and match it with your sidebar’s ID.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 9 best WordPress auction plugins and how to save partial form data in WordPress.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[63% OFF Today!]
[63% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]