browse by category or date

About two or three months ago, I started using Dynamic Widgets to regulate how the *ehm* Google’s Ads is showing in the sidebar. This is due to Google’s policy on how many number of ads can be displayed in a page.

I was happy 🙂 Dynamic Widgets user interface is really easy. You just need to declare your sidebar widgets as a dynamic instead of static. Then continued by define the rules that regulate when that particular widget is shown or hidden by clicking list of check-boxes describing the conditional logic.

Sadly, today I found out that the Dynamic Widget is broken. It didn’t recognize that the current page is a Tags archive page. The result is obvious, it disregard any logical conditions that I previously set and messed up my sidebar.

It is very likely that my recent upgrade to WordPress 3.3.1 is the primary cause. Since I don’t want to revert to previous WordPress version, I look out for replacement. Then I found out Widget Logic. If you are familiar with Boolean logic, Widget Logic is super effective. Instead of clicking check-boxes for configuration, you write your own logical condition. Widget Logic only evaluate those widgets that have something in their ‘Widget logic’ field. If their ‘Widget logic’ field is empty, the widget is simply treated as static widget.

As you can see, the logical condition is composed using WordPress’s functions. Here are the list of WP’s commonly-used functions that could help you:

  • is_front_page()
  • is_page()
  • is_single()
  • is_tag()
  • is_category()
  • is_archive()

For complete list of functions, you could refer to WordPress documentation.

And if you’re not familiar with Boolean logic, you could learn how to do it HERE.

Quick Example

!is_tag() && !is_page() && !is_single() && !is_category()
This widget will be shown if the current page:

  1. is not a Tags page, and
  2. is not a Page (not a Post), and
  3. is not a Single post, and
  4. is not a Category page

I hope it helps, cheers!

GD Star Rating
loading...
Goodbye Dynamic Widgets, Welcome Widget Logic, 4.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Incoming Search

blogging, php, wordpress

2 comments so far

Add Your Comment
  1. Great post. I was just wondering how what code would you use if you want show the widget only with the posts of certain category? Looking forward to your reply…

  2. There is a function to test the current post belongs to which category in_category()