0
votes

I have two widget areas in my theme, sidebar and footer. Now I have developed few widgets. Is it possible to restrict a widget to a specific area? For example, widgetA can only go to sidebar, but not to Footer area. Similarly widgetB can only go to footer but not sidebar? The reason for doing is that some widget's CSS style does not fit in sidebar, or footer. Thanks.

1

1 Answers

1
votes

in the code that displays your widget, you could use http://codex.wordpress.org/Function_Reference/is_active_sidebar to determine if you were in the footer or the sidebar and then only display your widget if you are in the correct place

e.g.:

if( is_active_sidebar( 'footer' ) {
    // display widget
} else {
    // do nothing
}