Widget Logic is_active_sidebar fix

Dec 29, 2011 Update – Installing Widget Logic version 0.51 fixes the previous is_active_sidebar issue. Thanks to Alan Trewartha for continued development on this essential plugin. Carry on.

WordPress doesn’t currently have a built in feature for controlling which pages a sidebar widget displays. The Widget Logic plugin adds this feature quite nicely if you’re comfortable using WP‘s conditional tags.

It does have built in, however, the function is_active_sidebar to test (TRUE/FALSE) if a dynamic sidebar is in use. Using this function in your themes is probably considered best-practice these days; read more about it (and sidebars in general) here: Sidebars in WordPress (Justin Tadlock, Nov 2010).

With these two items you’re mostly good to go, except for one small issue. Widget Logic has a bug(?) that returns is_active_sidebar true, even when widgets have been hidden. So even though the widgets don’t show, any markup you’ve added to the entire widget area¬†on the page will.

Luckily there’s a workaround found on the WordPress.org forums that addresses this problem: [Plugin: Widget Logic] is_active_sidebar() doesn’t work. Vasya Pupkin modified the Widget Logic plugin to fix the issue, and posted the code here: http://pastebin.me/002f3ec3145f4e1896a9cf79e72aebb2

The fix is working great for this site, and hasn’t seemed to break anything. Be careful, however – The plugin author has concerns about the approach breaking sites, so use the modified version at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ready for a refreshing experience on your next website design?