How to: Create Custom Sidebars with Widget Logic

With the addition of custom menus in WordPress, it has become much easier to define your own menus. However, it still does not give the ability to make entirely custom sidebars. There are some of you out there who would prefer to have complete control over all of your sidebars and where specific widgets will be shown.The Widget Logic plugin essentially gives every widget a new field where you can specify where it should appear. You may want to have a custom sidebar on every single page on your WordPress blog, and Widget Logic is just the right tool to achieve this.

Install Widget Logic

The plugin is available to download on the WordPress plugins directory. You could also install the plugin from your WordPress website. There is virtually nothing to configure at all. You just install and activate and you are ready to go.

Using Widget Logic

Widget Logic may seem a little confusing at first, however you just need to get yourself acquainted with WordPress’ conditional tags. They are essentially quite simple to understand.

Let’s say you have three pages: Home, About and Contact. If you would like a widget to simply appear on the homepage only, you would need to visit the widget configuration page on your WordPress website and open the widget to display it’s settings. A logic field will now viewable and you will be able to enter a conditional tag to choose where to display this widget. To display this widget purely on the homepage, you would enter the following:


As you can see, it is fairly simple to define where your specific widgets will be shown. However, if you would like to display this widget on a page other than the homepage, you would need to know the Page ID of that particular page. To find the out a Page ID, go to your page list on your WordPress blog and hover over a page. You will be shown the links destination and at the end of the link, you can see the ID of that specific page.

Once you have acquired the specific Page ID’s that you need, you will need to implement them in to the following code:


I have used the Page ID’s one, three and five for this example. The above code means that only those three pages will be shown on that pages relative sidebar.

Advanced Logic

There are several other tags that can be used within the logic field that can be classed as somewhat advanced, such as:

This tag will make this widget only viewable to administrators only :


This widget is only viewable to those who have reached the page through a google search :

[php]strpos($_SERVER[‘HTTP_REFERER’], "")!=false[/php]

This widget will appear for posts tagged with “featured” :

[php]has_tag (‘featured’)[/php]

For all posts in the “WordPress” category :


You can find more advanced widget codes on the plugin author’s website. I hope you found this guide useful, tell us if you find this plugin useful!



Hi, I'm Smair Habib. I am a freelance blogger and writer. I have been a consistent wordpress user for well over four years.

Related Articles


5 thoughts on “How to: Create Custom Sidebars with Widget Logic”

  1. Thanks Shamir, I am using the “1.has_tag (‘featured’)” and substituted a zip code # between the (‘ ‘) which will display a local Tennessee USA Banner in the second row when you search zip 37307. Shamir were are you located; do you ever search for American made products? You can leave me a message on the Refer / Comment page.

  2. Hi! Very helpful. Thanks for posting! 

    One thing worth noting is that,
    didn’t work for me. The widget would appear on page 1, but not on 3 or 5

    Instead I used: 

Comments are closed.


Create Your Own

Building beautiful WordPress websites has never been easier. Explore the visual drag & drop Theme Builder that does it all, and works on any theme. Coding skills needed: none.