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.
The configuring and options are in the usual widget admin interface.
BIG UPDATE: Now you can control widget in Gutenberg Widgets editor as well as in Classic Editor. It is just as easy as before but also in Gutenberg view.
Widget Logic uses the external service to obtain up-to-date information about the results of football matches. widgetlogic.org is a source of sports information, that provides a wide range of information about football, including various leagues, tournaments, and championships from around the world.
Other Notable Features
Here are a few other notable features of this free
Widget Logic plugin.
widget logic
conditional tags
gutenberg widgets
Screenshots
FAQ
Yes, you can! Starting from 6.0.0 you can use Widget Logic in Gutenberg widgets and in Classic Widgets. So if you have earlier version, please update plugin.
Switch to the default theme. If the problem goes away, your theme may be interfering with the WP conditional tags or how widgets work
Try the wp_reset_query option. If your theme performs custom queries before calling the dynamic sidebar this might help.
Try a different ‘Load logic’ point. Most wordpress conditional tags only work ‘after query variables set’, but some plugins may require evaluation earlier or later.
The ‘Evaluate widget logic more than once’ option may be needed if you have to use an early ‘Load logic’ point.
You have a PHP syntax error in one of your widget’s Widget Logic fields. Review them for errors. You might find it easiest to check by using ‘Export options’ and reading the code there (Though be aware that single and double quotes are escaped with multiple backslash characters.)
If you are having trouble finding the syntax error, a simple troubleshooting method is to use ‘Export options’ to keep a copy and then blank each Widget Logic field in turn until the problem goes. Once you’ve identified the problematic code, you can restore the rest with ‘Import options’.
This is often, not always, fixed by trying the different ‘Load Logic’ options. The ‘after query variables set’ option looks like it might be a better default, try it.
Since v .50 the widget logic code runs such that when dynamic_sidebar is called in a theme’s code it will ‘return false’ if no widgets are present. In such cases many themes are coded to put in some default sidebar text in place of widgets, which is what you are seeing.
Your options, if you want this default sidebar content gone, are to either edit the theme, or as a work around, add an empty text widget (no title, no content) to the end of the sidebar’s widget list.
There is some confusion between the Main Page and the front page. If you want a widget on your ‘front page’ whether that is a static page or a set of posts, use is_front_page(). If it is a page using is_page(x) does not work. If your ‘front page’ is a page and not a series of posts, you can still use is_home() to get widgets on that main posts page (as defined in Admin > Settings > Reading).
I believe this is fixed in 5.7.0. Let me know if that is not the case.
If your theme calls the sidebar after the loop you should find that the wp_reset_query option fixes things. This problem is explained on the is_page codex page.
Take care with your conditional tags. There is both an in_category and is_category tag. One is used to tell if the ‘current’ post is IN a category, and the other is used to tell if the page showing IS for that category (same goes for tags etc). What you want is the case when:
(this page IS category X) OR (this is a single post AND this post is IN category X)
which in proper PHP is:
is_category(X) || (is_single() && in_category(X))
Have a go at it yourself first. Check out the ‘Writing Logic Code’ section under Other Notes.
This is sort of deliberate. I originally wrote it to be as flexible as possible with the thought of writing a drag’n’drop UI at some point. I never got round to it, because (I’m lazy and) I couldn’t make it both look nice and let you fall back to ‘pure code’ (for the possibilities harder to cater for in a UI).
The plugin Widget Context presents a nice UI and has a neat ‘URL matching’ function too.
It might be that your theme performs custom queries before calling the sidebar. Try the wp_reset_query option.
Alternatively you may have not defined your logic tightly enough. For example when the sidebar is being processed, in_category(‘cheese’) will be true if the last post on an archive page is in the ‘cheese’ category.
Tighten up your definitions with PHPs ‘logical AND’ &&, for example:
is_single() && in_category('cheese')
Contributors and developers
“Widget Logic”
is open source software. The following people have
contributed to this plugin.
I’ve used this plugin for years, but as of the v6.0 rewrite and change of plugin author, it includes some kind of live soccer match results and calls to external JS. It’s bad, and as of WP 6.8.1 it breaks sites completely. I’ve gone back to v5.10.4 and rolled that out to my customers, but changed the folder name so WordPress doesn’t try to update it to a bad v6.x version. Unfortunately this probably means you’ll also have to use the Classic Widgets plugin and not be able to use block editor in widgets… or migrate your site to use reusable blocks and insert those into a widget. Hopefully this helps someone else avoid the pain.
Simon Foxe
June 7, 2025
|
Beware, it’s now a malware
This plugin is now containing a malware with arbitrary JavaScript injection. Look for alternatives as soon as possible
Francesco Canovi
June 6, 2025
|
Hijacked plugin, stay away!
displays some weird soccer scores without consent. STAY AWAY!!
displays some weird soccer scores without consent. STAY AWAY!!
mc64
October 1, 2025
|
Do not use this plugin anymore!
I’ve used this plugin for years, but as of the v6.0 rewrite and change of plugin author, it includes some kind of live soccer match results and calls to external JS. It’s bad, and as of WP 6.8.1 it breaks sites completely. I’ve gone back to v5.10.4 and rolled that out to my customers, but changed the folder name so WordPress doesn’t try to update it to a bad v6.x version. Unfortunately this probably means you’ll also have to use the Classic Widgets plugin and not be able to use block editor in widgets… or migrate your site to use reusable blocks and insert those into a widget. Hopefully this helps someone else avoid the pain.
Simon Foxe
June 7, 2025
|
Beware, it’s now a malware
This plugin is now containing a malware with arbitrary JavaScript injection. Look for alternatives as soon as possible
displays some weird soccer scores without consent. STAY AWAY!!
mc64
October 1, 2025
|
Do not use this plugin anymore!
I’ve used this plugin for years, but as of the v6.0 rewrite and change of plugin author, it includes some kind of live soccer match results and calls to external JS. It’s bad, and as of WP 6.8.1 it breaks sites completely. I’ve gone back to v5.10.4 and rolled that out to my customers, but changed the folder name so WordPress doesn’t try to update it to a bad v6.x version. Unfortunately this probably means you’ll also have to use the Classic Widgets plugin and not be able to use block editor in widgets… or migrate your site to use reusable blocks and insert those into a widget. Hopefully this helps someone else avoid the pain.
Simon Foxe
June 7, 2025
|
Beware, it’s now a malware
This plugin is now containing a malware with arbitrary JavaScript injection. Look for alternatives as soon as possible
displays some weird soccer scores without consent. STAY AWAY!!
mc64
October 1, 2025
|
Do not use this plugin anymore!
I’ve used this plugin for years, but as of the v6.0 rewrite and change of plugin author, it includes some kind of live soccer match results and calls to external JS. It’s bad, and as of WP 6.8.1 it breaks sites completely. I’ve gone back to v5.10.4 and rolled that out to my customers, but changed the folder name so WordPress doesn’t try to update it to a bad v6.x version. Unfortunately this probably means you’ll also have to use the Classic Widgets plugin and not be able to use block editor in widgets… or migrate your site to use reusable blocks and insert those into a widget. Hopefully this helps someone else avoid the pain.
Simon Foxe
June 7, 2025
|
Beware, it’s now a malware
This plugin is now containing a malware with arbitrary JavaScript injection. Look for alternatives as soon as possible