Recently, a client with a custom WordPress site we built wanted to display different text in a single sidebar widget on each top level page so when a visitor clicked through the navigation, the sidebar content in that one particular widget would change.
This can be accomplished in many ways, but one solution is through the use of the WordPress plug-in Widget Logic.
The plugin gives every widget an extra field where you can use WordPress’ conditional tags to control what page(s) your widgets appear on.
For example:
- You want a widget only to appear on your about page but not any others
- You want a video in the sidebar to auto play on the home page, but not on any other page
- You want a different testimonial to show up in the testimonial widget on each page
- You want to offer different opt-in offers on different website pages
- You want to display a specific widget only on posts by a certain author or in a specific category
With Widget Logic, you can drag a new widget into your sidebar, add the conditional tag is_page( ‘about’ ), and the widget you just created will only appear on the about page.
For the client example above, you would need to create a different widget for each page and assign each widget to each page using a conditional tag. I would use the WordPress page ID conditional tag is_page( ’45′ ) changing the number for each widget to match the actual page ID you want the widget to appear on.
Through the use of WordPress’ conditional tags you can also specify unique widgets at a broader scale such as pages, posts, templates, authors, categories, tags, etc.
As a reminder, before installing and testing a new plugin that you are unfamiliar with, completely back-up your WordPress files and database in case your theme isn’t compatible.
WordPress Shortcuts to Speed up Formatting Your Blog Posts
Adding Google Authorship To Your WordPress Site
What is a Blogsite and What is WordPress?
How to Add the Facebook Like Box to Your WordPress Site
WordPress 3.3 Is Released!

There are designers that can make it pretty, coders that can make it work, and marketers that can make it sell — at
Bourn Creative is a 

Brian, Thanks so much for the tips on widgets. Although I am not super tech savvy, I now have you as a great resource!! Love your Bourn Creative work!!
Thanks Renee.
I can see that there’s so many creative ideas I hadn’t thought about (and suspect I don’t have the techie skills to master). Thank heaven for folks like you, Brian!
Don’t be afraid to experiment, but be sure you have complete backups of your site before trying something you are unfamiliar with.
Thanks Jennifer! I use WP for both of my blogs. Now I see that I’ve got some homework to study!
Great tip, but not something I’ll do myself, LOL! I was searching for just such a solution not long ago, I’ll let my techie person know. Thanks!
Just when I think WordPress can’t get any cooler, you introduce me to a nifty new widget. I love this idea. Guess what I’ll be doing this week:)
Glad you like it. Let us know how it works out for you, and thanks for stopping by our blog.
Thanks Jennifer. It’s a pleasure to meet you. It appears we have a lot in common starting with our love of WordPress! Thanks so much for the widget tips.
Thanks for the widget info. I have a wordpress site with widgets on my side bar that allow for different testimonials on different pages. I’m wondering if it’s the same plug in or something else. I have some things on my sidebar that need to be updated. Thank goodness for tech savvy folks like you!
Tiffany – there are thousands of plug-ins available and we test out a lot of them – this one is one of our favorites though!
Definitely something I’ll use in the future …
Thanks for the info.
Doesn’t work with on my site though.
I have set: is_page(’5′) for a widget that I only want to display on the page that ends in “post.php?post=5&action=edit”
5 IS the pages number, no?
Any idea why it doesn’t work?
Tomas
Tomas, your code looks like it might be a little off. Try is_page( 5 ). Note the spaces and the no quotes around the page ID. Take a look at the Codex page I have linked to in the article for all of the conditional tags you can use and their proper syntax.
I am having some trouble getting Widget Logic to work completely on my site (http://hinterlandgazette.com). I have a customer who wants to run his ads only on the Crime and Justice section of my site. I got the code to work with in the header widget box:
is_category(‘crime-and-justice’) || (is_single() && in_category(‘crime-and-justice’))
I have a second widget box in the header to run all Adsense ads on other sections and I used:
‘is_category(‘crime-and-justice’) || (is_single() && in_category(‘crime-and-justice’))
When I go back to the site and click on the individual posts in Crime and Justice, the Adsense ads pop up and not the customer’s ad. What did I do wrong?
I moved my blog from Blogger to WordPress and used the customer URL permalink (/%year%/%monthnum%/%postname%.html). Not sure if that’s the problem.
Please help, I’m about to lose a customer.
I think your conditional syntax is a little off and that may be what is not working for you. If you go back to the WordPress Codex you should see that in_category uses the category id and not the slug.
Also, you may want to check the “reset query” checkbox on your widgets page that Widget Logic adds. Some themes have issues using this plugin and that can sometimes resolve them.
Thank you very much! It works for my blog
Was wondering how to set a unique widget for every post/page and this plugin, Widget Logic, seems to be an excellent resolution. So great work Brian, really appreciate your insight!
If you need add unique content for every page or post outside the WordPress post editor, a widget and this plugin would not be a good solution. For something like this, using custom fields or custom meta boxes would probably be best.