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.
Instructions:
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. */ register_sidebar( array( '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