Description
This plugin gives every widget an extra control field called “Widget logic” that lets you control the pages that the widget will appear on. The text field lets you use WP’s Conditional Tags, or any general PHP code.
PLEASE NOTE The widget logic you introduce is EVAL’d directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter ‘widget_logic_eval_override’ which you can use to bypass the EVAL with your own code if needed. (See Other Notes).
There is also an option to add a wordpress ‘widget_content’ filter — this lets you tweak any widget’s HTML to suit your theme without editing plugins and core code.
DONATIONS
If you like and use Widget Logic you could consider a small donation to Cancer Research UK. I have a JustGiving.com donation link. As of February 2017 we have raised 1,048.50 UKP.
WRITING LOGIC CODE
The text in the ‘Widget logic’ field can be full PHP code and should return ‘true’ when you need the widget to appear. If there is no ‘return’ in the text, an implicit ‘return’ is added to the start and a ‘;’ is added on the end. (This is just to make single statements like is_home() more convenient.)
Source: Widget Logic
32 Comments