Widget Logic with WordPress Conditional Tags Solution
WordPress Users are wanting a CMS, not a BlogI'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 ManagementLet'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" basicsThere 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 SectionsThere 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) |
Latest News & UpdatesRelated ArticlesAdd a Forum POLL |
If you are looking for company information, details relating to our services, products, or you need to contact Pixel Theme Studio, the following directory should help:
Pixel Theme Studio is focused on designing professional WordPress themes and premium Joomla Templates (this site is in Joomla). The goal is to design real world concepts for individual bloggers and business owners with themes that are not bloated with scripts and code. We create the best WordPress themes and Joomla templates possible by keeping the designs simple and clean.
Sybergen Certified
Comments
http://wordpress.org/extend/plugins/conditional-widgets/
You are doing fine but there is just one mistake. Intead of using || use &&. :)
I want to do a multi-lingual site, so I was gonna see if I coud do "templates, w/ custom sidebars, and customize w/ "widget logic"
Wish me luck ;)
http://wordpress.org/extend/plugins/custom-sidebars/
Your very welcome...not as easy as the Joomla method which is just a couple mouse clicks but the Widget logic method works once a person gets used to it.
You would think WordPress would make it easy to say "not here" for conditionals, but then it would make it too easy...haha. Actually, it would be nice if the Widget logic method was part of WordPress.
For the request of combinations that the WP site doesn't show, I just might do that as a follow up to this article regarding conditionals in Widget Logic. I made a note to look into this and provide a sort of reference guide.
By the way, should not be using ! in front of conditionals for the widget logic.
I still can't find anywhere an example of Not on this page AND Not on this Page, (meaning one widget not on home-static, nor page 19).
I tried:
!is_page('home') || !is_page('19')
but no go.
When I have it as just
!is_page('home')
it works - ie, doesn't show on home/front_page.
Would appreciate a post on combinations, or if not possible, I can probably find other solutions (in templates, or reverse on every widget).
Thanks again for this great post. It has really got me going finally.