Widget Logic with WordPress Conditional Tags Solution

widget-logicI’ve talked about this with several users of my themes but decided to write a quick tutorial for everyone to learn how to take advantage of a WordPress plugin called “Widget Logic” and how “WordPress Conditional Tags”  work in conjunction with your own web site. To be honest, I think this should be a standard function with WordPress so you don’t feel stranded with limitations.

WordPress Users are wanting a CMS, not a Blog

I’ve noticed over the past year or more, people are determined to make WordPress – a blogging platform – a fully functional cms. For the record, WordPress is “NOT” really meant to be a full cms like you will find Joomla is ideally best for this. There are those who are still stuck in the world of WP because it’s what they have always used or someone told them it’s the only option…

Rather than fight the popularity of WordPress, it’s one of the reasons why you are starting to see more advanced looking and functional themes being developed as cms web site alternatives, albeit, with the optional “blogging” feature maintained within their web site. So things now became a lot more complicated for the end-user because WordPress as a cms is more complicated to design and develop for, and if you think WordPress is easy, wait until you try to start using it as a cms.

Using WordPress as a CMS with Flexible Widget Management

Let’s face it, WordPress widgets are an absolute joke and need a complete overhaul. They are one of the least flexible and if you want anything more than the standard widgets, you NEED Programming skills. So what can you do until you learn php and the inner workings of WordPress?

Managing Widgets with “some” basics

There is one plugin you can download, called “Widget Logic” that you can use to manage the placement of your website or blog widgets. By default, widgets are dragged into the widget positions from within the widget manager of your WP admin area, but the downside is that they will show up on every page that has that position. But what if you don’t want it everywhere? Without a plugin like Widget Logic (there are others too), you are out of luck.

Basically what Widget logic does is add a small form field at the bottom of every widget you have. When you drag a widget into a position, you enter in WordPress conditional tags (actually, just one tag) based on where you want to display it within the front-end of your web site. Here is an example:

EXAMPLE 1 – Lets say you want to show a widget only on the “About Us” page which has a page ID of 3 (which you can see when the page is open in the admin) in the right column. With the widget dragged into the “right” column (sidebar), you would then add this conditional tag into the Widget Logic field: is_page(3) and then click Save. On the front of your site, this widget will now only show on the About Us page in the right column.
EXAMPLE 2 – Lets say you have the Static Front Page feature for your site – which basically means your front page is not the blog page now, it’s a static page – and you want to show a header with an image. You create your Text Widget with the image path added into the content area and then you add the following conditional tag: is_front_page() and then save it. Now your widget (image header text widget) is shown on the front page but no where else.

The above examples lets you show widgets in selective locations throughout your website; letting you emulate a fully functional cms website with a little more control over your widgets and page layouts.

Putting the Same Widget for Multiple Sections

There are going to be times you may want the same widget to show in two different areas of your site, like the front page and for every single post page (or perhaps just one). Normally everyone thinks you have to drag another widget and do a complete copy for each area of your site, but if you did this, you would end up with a mile long widget admin.

The Widget Logic uses Conditional tags which also means you have some flexibility. Using more than one conditional tag in the Widget logic field is possible, so for example, lets say you want a widget to show on the front page but also on all single post pages (the page that you see when you click on an article in the blog to read the rest of it). Your conditional tag  would be this:

is_front_page() || is_single()

The example above basically tells the system to post it in the front page but also on “every” full post page. If you want just one particular post instead of all, then it would be this:

is_front_page() || is_single(3)
By | 2010-09-23T00:28:08+00:00 September 23rd, 2010|Categories: WordPress Tutorials|Tags: , , , |0 Comments

About the Author:

Leave A Comment