I enjoy simplicity, in everything. Unnecessary complexity is evil. Have a look at my WordPress plugins.

Conditional Widgets in WordPress

While working on a WordPress theme for a cliënt he stated that he wanted to have page dependent content in the sidebar. In other words, a sitewide widget wouldn’t do because he wanted to hook widgets to certain pages, posts or categories. For example: the homepage showed widget #1 while the contact and the about-me page showed widget #2.

I’ve started looking into some dynamic / conditional widget plugins. Some worked pretty good, some were flawed and most were just crap. These are the ones that I found to be quite helpful and with decent code quality, they might be of use to you too.

Widget Logic

This is my absolute favourite, although it might not be the best choice if you’re installing it so your cliënt (with no PHP knowledge) can use it later on. This plugin adds one small (but o so powerful) input field beneath every widget where you can specify any of WordPress’ conditional tags. This makes it possible to restrict a certain widget to a certain post, multiple posts, pages, categories, basically anything you like.

Of course, the downside is that the plugin user needs to know a thing or two about WordPress conditionals or PHP in general. If this isn’t the case you might be better of with one of the other plugins in this article. If the intended user has knowledge or is willing to look into WP Conditionals I highly suggest using this plugin though, as there are practically no limits.

» Widget Logic on the WordPress repository



Widget Context

This plugin adds some display options to all active widgets where you can specify some basic conditionals, as you can see in above screenshot. The nice touch is the textarea where you can specify certain URL’s to show the widget on. You are not limited to one URL and that makes this widget a perfect choice for users with no knowledge of WordPress conditionals. You can use some wildcards to match multiple URL’s with just one rule.

» Widget Context in the WordPress repository


Conditional Widgets

Like widget context, this plugin adds display options to all your active widgets where you can apply some conditionals where to show or hide the widget. Although you can’t restrict widgets to certain posts, you can add conditionals to show or hide the widget at certain category archives (+ posts inside that category) and certain pages only.

The code quality is above average (there is some crap out there..), it’s ease of use is perfect for cliënts with no understanding of PHP / HTML / any other webdevelopment language. All that’s needed is some basic logic.

» Conditional Widgets in WordPress repository



With either one of these 3 plugins you should be able to create a one-to-many relationship between widgets and posts. Do you know a plugin that takes care of creating ‘dynamic widgets’ in a neat and easy-to-use way that isn’t covered in this post? Let me know in the comments!

If you’re looking for a way to display content from your post in a widget area (a one-to-one relationship), i’m actually thinking about developing a plugin for this. There are some out there already, but the ones i’ve looked at are crappy coded and do not support visual editors. Like the idea? Let me know, I won’t make it if you won’t use it!

Share this post: on Twitter on Facebook

12 Responses to “Conditional Widgets in WordPress”

  1. Thanks for the positive review for our Conditional Widgets plugin. We wrote it for exactly the audience you described, the completely non-technical user. We host sites using the WP Multisite and loved the functionality of Widget Logic, but needed something that was a point/click UI.

    I hadn’t seen the Widget Context plugin. That one looks fantastic too.

  2. Thank you Danny for this nice overview! My personal favourite is “Conditional Widgets” – which is easy to use. I had some troubles with “Widget Context” and “Widget Logic” might be the most powerful – if you’re aware of PHP.

  3. Heya – the other developer from Conditional Widgets here (with Kevin who commented already).

    Just wanted to let you know I released 1.1 today that adds options for Search Results, 404 page, Date Archives, and Author Archives.


  4. Yes, I am interested in this.

    “If you’re looking for a way to display content from your post in a widget area (a one-to-one relationship), i’m actually thinking about developing a plugin for this.”

    Specifically, one that would display the entire post in a sidebar when user hovers over (or clicks) the usual excerpt in the loop.

    Thanks for asking.

    Let me know.

  5. I am looking for a way to change the content of the sidebar depending on the page being displayed.
    i.e. If I have a page on abundance I would have a link to an abundance e-book in the side bar. If I was on the health page, I would see the health e-book instead of the abundance e-book.

    Do you have something for this??

  6. Hi Steve,

    Using the first plugin (Widget Logic) would be best for this use case. However, you’ll need some WordPress and PHP knowledge for that.

    The 2nd plugin “Widget Context” might also be right for you, just target your pages by URL. Have a look at the screenshot above to see what I mean.

    Good luck!

  7. Genesis framework with Simple Sidebars works perfect for me. Not sure if you can assign different widgets on cathegory pages but you can assign widgets on a “per page” or “per article” basis.

  8. I love Widget Logic which I use with custom layouts that have their own sidebars.

    But need to be able to show content within a widget for a set amount of time only.

    Someone turned me on to Dynamic widgets which will allow you to set dates but not length of time.

    Ie: when a visitor shows up, the widget is shown for 5 minutes. I then want a second widget to be shown next.

    May need custom coding, but perhaps there is some WP plug-in that has dynamic content switching that you can set parameters on.

    If you have any ideas let me know.

Leave a Reply