Widget Logic Lets You Show or Hide Widgets from Posts and Pages.

So you have a nice theme for your blog, but not sure about how to adjust widgets of your choice in the pages you wish? Looking for a solution to display widgets like adsense ads, related post widget, Facebook like box, recent comments or any such widget only in home page, or particular article, or in a category post? Then you have come to a right place to get an ideal solution without any major knowledge to change the theme’s source code. In this article I’m going to share some information about Widget Logic, a plugin which i use to adjust my widgets to appear in pages that I wish. this plugin works basically on WordPress conditional tags, and its very simply to manipulate. Not only that Widget Logic lets you control on which pages widgets appear using WP’s conditional tags. It also adds a ‘widget_content’ filter, by this you can tweak standard widgets to suit your theme standards without editing plugins and theme’s code.

If you are curious about WordPress conditional tags which I’ve been referring. You can check the detail explanation on Conditional Tags in WordPress support page.

What widget logic lets you do is basically gives you a text field to add WP’s conditional tags or any PHP code which can control your widgets as you wish.

Some basic conditional tags which you might have to use are:

  • is_single() – This will restrict widgets to appear only in post page like the one you are reading right now. You can also configure it with particular post id. for ex: is_single('17')". . This is restrict the widget to display only in post number 17. (If you are not sure about a particular post ID, then just go to edit post and click on “Get Shortlink” button next to the permalink field and you will get something like this: https://techgyo.com/?p=2916 .) If you are still confused, just drop your comments below.
  • is_home() –      Use this conditional tag if you want to display a widget only in home page.
  • is_front_page() – this has the same funtionality as the is_home tag, But it actually returns true when the main blog page is being displayed and the ‘Settings > Reading ->Front page displays’ is set to “Your latest posts”, or when ‘Settings > Reading ->Front page displays’ is set to “A static page”.
  • is_single(‘Post Title’) – I hope you got the logic, this conditional tag returns true for a particular page with the post title as post title.
  • is_category(‘category name’) – Returns true for all the articles in a particular category.

Other than these , you can also enter codes in a array combination or like below:

is_single() && in_category('cheese')
Example:

Here in the below example, I’ve added a conditional code is_single() for a sponsors widget. And the result of this is shown the nest image.

widget logic wordpress conditional tag.
CONFIGURING WIDGET WITH CONDITIONAL TAGS.

Result:

HOME PAGE widget & POST PAGE widget OMARISON
The sponsors widget is not appearing in the home page

So that your widget will appear in single post page and additionally in posts under a particular category.

There is also an option to add a wordpress ‘widget_content’ filter — this lets you tweak standard widgets to suit your theme without editing plugins and core code.

Update: I just noticed that this is my 100th post in this blog!

We’ve also discussed about some other plugins like:

Info:

Type: WordPress plugin.
Compatible up to: 3.0.1
Author:Alanft

Download from official WordPress page.

Widget Logic Lets You Show or Hide Widgets from Posts and Pages. 1
Sreejeshhttps://techgyo.com
Hi there! I'm +Sreejesh and I am an internet enthusiast. I started writing on this blog as a hobby, now full time blogger. In this blog, I cover topics about blogging, and how to make money online, and also some interesting techy news, tips and tutorials. Checkout archives

Grab your lifetime license to AI Image Generator. Hostinger Hosting

X