[Plugin: Widget Logic] Issues with “Recent Posts” widget
-
I’m using the Widget Logic plugin to “not display” most widgets on posts that are in a specific category (or that category’s archives), so my logic looks like this:
(!is_category('49') && !in_category('49'))
It’s been working perfectly… until I added a “Recent Posts” widget into the mix. Once I did that, the widgets below the “Recent Posts” widget stopped displaying at all… but only sometimes. ?? You may know where I’m going with this…
I eventually figured out that if the last of the five most recent posts (5 being the default setting for the “Recent Posts” widget) was in category 49, the remaining widgets disappeared.
As best I can figure, that’s because the global $post variable is changed during the “Recent Posts” and my widget logic is checking it and coming back false.
I’ve solved this for my own purposes by editing the plugin to store the original $post variable in a temporary variable when first loading the page, and then to reassign $post before rendering each widget. There’s probably a much more elegant way to do it, but I thought I would at least tell you about the issue and my solution in case you want to update the plugin.
- The topic ‘[Plugin: Widget Logic] Issues with “Recent Posts” widget’ is closed to new replies.