No credit card. Takes under a minute.

Login
INSIGHTS2 MIN READ

How To Control Where Widgets Appear Using WP's Conditional Tags

trevoreddy

Published on October 1, 2015

Published on Wealthy Affiliate — a platform for building real online businesses with modern training and AI.

Let's say you need to control where you display your sidebar widgets and you want a lightweight and flexible solution. This can easily be achieved by leveraging my preferred Wordpress plugin and using Wordpress's conditional tags

1. Install and active the Widget Logic plugin: https://wordpress.org/plugins/widget-logic/
2. Go to appearance > widgets and expand the widget you'd like to control. Find the "widget logic" field at the bottom.

3. You will have to use WP conditional tags to control where the widget is displayed. As an example, let's say you want to show a banner ad on a particular post and no where else. You would add the following code to the sidebar item in the "widget logic" field:

Ready to put this into action?

Start your free journey today — no credit card required.

is_single(99) && in_category('category-name')

Replace the number '99' with the ID of your post and 'category-name' with the category slug of the post's category. To find the ID of your post, go to Posts in your WordPress admin, and click the post you need the ID of. Then, if you look in the address bar of your browser, you'll see something like this:

http://example.com/wp-admin/post.php?post=1280&action=edit

The number, in this case 1280, is the post ID.
Voila! Your banner ad will now only display on that post! Easy. There are many other ways to use conditional tags with this plugin which are all explained here: https://wordpress.org/plugins/widget-logic/other_n...

Read more about WP conditional tags here: https://codex.wordpress.org/Conditional_Tags

Good luck!

Trev

Share this insight

This conversation is happening inside the community.

Join free to continue it.

The Internet Changed. Now It Is Time to Build Differently.

If this article resonated, the next step is learning how to apply it. Inside Wealthy Affiliate, we break this down into practical steps you can use to build a real online business.

No credit card. Instant access.

2.9M+

Members

190+

Countries Served

20+

Years Online

50K+

Success Stories

The world's most successful affiliate marketing training platform. Join 2.9M+ entrepreneurs building their online business with expert training, tools, and support.

Member Login

© 2005-2026 Wealthy Affiliate
All rights reserved worldwide.

🔒 Trusted by Millions Worldwide

Since 2005, Wealthy Affiliate has been the go-to platform for entrepreneurs looking to build successful online businesses. With industry-leading security, 99.9% uptime, and a proven track record of success, you're in safe hands.