Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Create unlimited sidebars

Hi guys, I want to let the user create unlimited sidebars on WordPress. But I don't know how to do it, do you know any tutorial about this? I would like to add a button in the Widget area: Add Sidebar and a field to add a name for that sidebar. Any idea?

3 Answers

I find a plugin to create unlimited sidebars: https://wordpress.org/plugins/sidebar-generator/ But I want to make it without a plugin. :D

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

If you don't want to use a plugin you will have to add the necessary code to your theme functions.php file. However, there is a question as to whether this code belongs in a theme or in a plugin. If someone switches themes and they loose the ability to create unlimited sidebars is that going to be a problem? If so, the code belongs in a plugin, if not, you can code into your theme.

Thanks for the answer. I was thinking to add the code in the functions.php of the theme. If the user change the theme he loose the ability to add new sidebars, but the already created sidebars stay there, right?