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.

Is it possible to add a checkbox to all widgets loaded into sidebars? For example, I'd like to allow the site owner to choose whether any widget should appear on the home page, inside pages, both or neither.

I'm thinking a checkbox interface appended to the widget control interface.

Has anyone done something like this and what level of complexity are we talking?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

There are plugins that can do this like Widget Context or Widget Logic.

If you want your own solution then it's pretty easy:

  • hook your function with the checkbox on in_widget_form
  • hook your widget update function widget_update_callback (update the widget option)
  • check if the option was checked using the widget_display_callback hook (return false if it is)

Post what you have so far if you need sample code. I've implemented a feature like this in one of my themes...

share|improve this answer
    
Thanks, I'll check out the plugins for some examples. In your outline, is that widget-specific or a global function that would intercept any widget that's updated? –  N2Mystic Jun 30 '11 at 1:01
    
it's global, works for all widgets using the 2.8 api... –  onetrickpony Jun 30 '11 at 1:36
    
Thanks for your help! I've taken your suggestions and got a pretty good start. I'd welcome your code example or any pointers you might have. I've posted the code here > wordpress.stackexchange.com/questions/21975/… –  N2Mystic Jul 4 '11 at 21:33
add comment

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.