WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Widget Logic

Widget Logic lets you control on which pages widgets appear using WP's conditional tags. It also adds a 'widget_content' filter.

  1. Upload widget-logic.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. That's it. The configuring and options are in the usual widget admin interface.

Configuration

Aside from logic against your widgets, there are three options added to the foot of the widget admin page (see screenshots).

  • Add 'widget_content' filter -- This allows you to modify the text output in all widgets. You need to know how to write a WP filter, though some basics are covered in Other Notes.

  • Use 'wp_reset_query' fix -- Many features of WP, as well as the many themes and plugins out there, can mess with the conditional tags, such that is_home is NOT true on the home page. This can often be fixed with a quick wp_reset_query() statement just before the widgets are called, and this option puts that in for you rather than having to resort to code editing

  • Load logic -- This option allows you to set the point in the page load at which your widget logic starts to be checked. Pre v.50 it was when the 'wp_head' trigger happened, ie during the creation of the HTML's HEAD block. Many themes didn't call wp_head, which was a problem. From v.50 it happens, by default, as early as possible, which is as soon as the plugin loads. You can now specify these 'late load' points (in chronological order):

    • after the theme loads (after_setup_theme trigger)
    • when all PHP loaded (wp_loaded trigger)
    • during page header (wp_head trigger)

    You may need to delay the load if your logic depends on functions defined, eg in the theme functions.php file. Conversely you may want the load early so that the widget count is calculated correctly, eg to show an alternative layour or content when a sidebar has no widgets.

Requires: 2.8 or higher
Compatible up to: 3.8.3
Last Updated: 2014-2-1
Downloads: 764,012

Ratings

4 stars
4.3 out of 5 stars

Support

5 of 24 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,2,2
100,1,1 100,6,6
100,1,1 100,9,9
100,8,8
100,1,1 0,1,0 0,1,0 78,18,14 100,4,4
86,14,12 100,36,36 100,1,1 0,1,0
87,31,27 0,1,0
96,49,47
100,1,1
100,7,7
100,11,11 0,1,0
100,3,3 100,1,1 0,1,0
95,37,35 100,7,7
100,8,8
100,12,12
100,18,18
100,2,2
100,6,6
95,58,55 100,1,1 100,1,1
100,7,7 0,1,0 91,11,10 100,1,1
96,53,51 100,6,6
100,4,4 97,29,28 0,1,0
100,6,6
89,38,34 0,6,0
93,28,26 100,1,1 100,1,1
60,5,3 20,5,1 100,5,5 69,13,9
92,36,33
100,3,3
83,6,5
100,7,7 100,1,1
100,6,6 67,3,2
70,10,7
87,15,13
100,1,1
100,1,1