Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm building a WP site that needs to have the ability for unique widgets on a per-section basis. I've built out the page structure of the site, then built the sidebar structure of the site. It goes like this...

Services (section - uses Services sidebar)
    Service Name (page - uses Services sidebar)
    Service Name (page - uses Services sidebar)
Industries (section - uses Industries sidebar)
    Industry (page - uses Industries sidebar)
    Industry (page - uses Industries sidebar)

While on a Service Name post creation page, I'd like to have a Select dropdown in a meta box on the side that allows for the selection of a registered sidebar. For instance, while creating a new Service Name page, I'd like to select the Services sidebar as the desired sidebar for that page. Then, I could reference that object in my sidebar.php file.

The reason I want this setup is because I have nothing to tie to that says "if this page falls under the Services parent page, I'd like this sidebar to show up every time." I could use conditionals and tie to page name, page ID, slug, etc... but this isn't flexible and doesn't fit the CMS request. What if the client changes Services to Our Services? what if they recreate the Services page and it gets a new ID? I can't restrict my client to these conventions.

I can't rely on Widget Logic plugin or anything like it because the client would have no idea how to use it; it clearly wasn't built for the technologically-challenged crowd.

Any help or advice with this would be super-helpful. And if my logic in how I'm building this isn't right, please feel free to tell me I'm a big dummy and explain how this would be done best.

Thank you!

share|improve this question

1 Answer 1

Sounds like you could use page templates for this. You'd create a file in your theme called 'page-services.php' (for instance). When users create new pages, they'd select the "Services" template, rather than the "Services" sidebar, but it's basically the same thing for your purposes. Here's how to set up templates: http://codex.wordpress.org/Pages#Page_Templates

And here's the conditional you could use to determine which template is being displayed (for use within your sidebar.php to swap out between sidebars): http://codex.wordpress.org/Conditional_Tags#Is_a_Page_Template

Hope this helps, best of luck.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.