Conditionally show custom widget in frontend sidebar
-
1. I’ve created a custom widget.
2. This widget is applied to a sidebar area that is active on multiple templates e.g. the archives and singles.
3. I would like to display the widget only if is_single() == true.There are multiple ways to go about doing that. I could register a new sidebar which would only display on single pages.
What I’d rather do, however, is somehow check the is_single() condition inside the custom widget class. Checking inside the widget() method does hide the content but the is_active_sidebar() still returns true, because it’s not aware of the hidden widget’s content.
What is the most appropriate way to handle this?
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Conditionally show custom widget in frontend sidebar’ is closed to new replies.