Sidebar is a cool feature of Modern Websites but everybody doesn’t like it. You like it or not, WordPress has a built in feature to add dynamic sidebars to your website.
To add the sidebar in our website, first we have to register the sidebar. Open your theme’s
functions.php file and add the bunch of code from this gist:
Don’t forget to update the ‘name’, ‘id’ and the ‘description’ to match your needs.
After adding this code, now refresh your widgets from the dashboard and you will see the new sidebar there. Cool! right?
Now we have to show this sidebar on the frontend of our website. to achieve this goal, open up your theme’s index.php or other files that needs this sidebar. Paste the following code inside php block. Don’t forget to update the id of your sidebar with the ‘my-sidebar’ text.
dynamic_sidebar( 'my-sidebar' );
Done! Now you will see the output of your sidebar.
Any Question? Send me an email.