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

Different Widgets on each page/post in WordPress

Looking for a solution for allowing users to add different widgets to different pages and posts without a plugin. Any ideas? Thank you in advance

2 Answers

Can you give an example or two of how you envision this working? Would just any site user be able to do this?

AFAIK, only admins have authorization to decide what widgets go where, so I'm thinking you'd need a plug in like User Role Editor to change user permissions in this regard.

Hi Joe,

So, basically I am looking into adding functionality to a WordPress theme I am developing at the moment to allow users to have the ability to add any sidebar to any post or page and even to create new sidebars if needed. So far I have managed to implement functionality to display all available sidebars in a drop down menu through a meta box on every post and page. So, at the moment the user can choose a sidebar for any post or page through the drop down list of registered sidebars. What I need now is to create an option to allow users to register new sidebars which can then be filled with widgets on the widget page under appearance and then chosen from the drop down meta box on pages and posts. I know it can get a bit messy if users start registering a ton of sidebars that's why the ability to change widgets on the same sidebar on different pages and posts would be a better approach but I am not sure it is possible as I have been searching exhaustively and cant seem to find at least an idea of how to achieve this.

Maybe a custom post-type would work here with a custom field to insert the widget.