Freaky Trigger’s WordPress Setup
Widget Logic
FT had a complex sidebar, but I decided to ‘widgetise’ it when Steve updated the theme in early 2008. To keep some of the special widgets appearing only when needed, I wrote a plugin to extend the functionality of widgets. Widget Logic allows widgets to appear or not depending on standard WP conditional tags, such as is_home() and is_single() and so on.
If you want to contact me about it you should address yourself to the WordPress org directory and perhaps post on the forum there. Or you can leave a comment here, below. PLEASE READ THE FAQ AND OTHER NOTES in the WordPress plugin directory first though.
If you find Widget Logic useful to you, then you could consider a small donation to Cancer Research UK – click ‘Donate’ on the widget over to the right there –>
VIDEO TUTORIAL! Popup or view on YouTube a screencast by Daryl Lozupone. Thanks to him.
Podcast Channels
Podcast Channels is a plugin that augments WP’s RSS feed with some extra elements, mostly in the ‘itunes’ namespace. It works with existing features of WP (auto-enclosures and the media library) to make a simple way to podcast, and allows different metadata in different RSS feeds – you can have as many channels as there are categories, tags, even blog authors.
Like a lot of people I found PodPress increasingly frustrating to use around WP2.6. I still see lots of people using it, but I found it was interfering with too many aspects of WP – wysiwyg editing, the media library, and so on. But there were only two things it did that I liked – show download stats, and allow multiple podcasts on a blog with their own rss and iTunes metadata. So i wrote a couple of plugins to target just those functions.
(I may release the stats plugin some day, but it’s nothing special, a bit clunky, and I really don’t want to support it.)
Freaky Trigger Theme
This was designed by Steve Mannion @ base58.com
Plugins FT uses
- Akismet by Automattic
- Cimy User Extra Fields by Marco Cimmino
- Contextual Related Posts by Ajay D'Souza
- Edit Comments by Andrew Sutherland
- FT Combo by Alan Trewartha
- Get Recent Comments by Krischan Jodies
- Google Custom Search Plugin by Aleem Bawany
- MediaElement.js - HTML5 Audio and Video by John Dyer
- More Fields by Henrik Melin, Kal Ström
- Organize Series by Darren Ethier
- Podcast Channels by Alan Trewartha
- Revision Control by Dion Hulse
- SABRE by Didier Lorphelin
- Widget Logic by Alan Trewartha
- WP-DBManager by Lester 'GaMerZ' Chan
- WP-Polls by Lester 'GaMerZ' Chan
- WP-Polls Widget by Lester 'GaMerZ' Chan
- WP-PostViews by Lester 'GaMerZ' Chan
- WP Google Analytics by Aaron D. Campbell
- WP No Category Base by iDope
wow, look at all of them. FT salutes you
admin in • 124,691 views

Hey Alan,
Great job on Widget Logic plugin. Got a curly one for ya!
I’ve hit an interesting corner case in the logic. My page slug actually contains the word “return” – the slug is “investment-returns”.
So my initial logic is_page(‘investment-returns’) was throwing unexpected $end errors.
I tracked it down to line 155 (I’m running version 0.47):
$wl_value=(stristr($wl_value, “return”))?$wl_value:”return (“.$wl_value.”);”;
In other words – if string CONTAINS the word return then use “as is” otherwise wrap in “return (…);” to evaluate to true/false.
Of course, in my case, the string DOES contain “return” – so it never gets “wrapped”.
I can code around it by putting “return (is_page(‘investment-returns’));” in my widget logic – but I’m giving this to my end-user to update and that could confuse them.
So, I have added an extra line after 155 to check that the condition STARTS WITH “return”:
$wl_value=(stripos(trim($wl_value), “return”)==0)?$wl_value:”return (“.$wl_value.”);”;
I’m sure there is a more elegant way of doing this – this is a quick hack.
Anyway – thought I’d pass it on. Hope this helps!
Steve
Great WordPress Plug-In, will be featured as the Plug-In of the day on our website on August 18th.
Thanks,
Jamie
steve – yes that issue has cropped up a couple of times with people. The problem with your 2nd workround is that often logic doesn’t have to start with ‘return’ – you can have multiple statements separated by ‘;’ and then the final one does a ‘return $value;’.
The only way to detect if a ‘proper’ return statement is in the string is a full parsing of the code – which is way beyond what I want to do with the plugin! My first pre-release version of WL opbliged you to supply full code like “return is_home();” but when it became obvious that 90% of logic would be a simple conditional tag, I added the code to wrap it in return ().
If you want to hide the complexity of full statements from your users, just mandate it always has to be a single statement, and then change that line 155 to ALWAYS wrap it.
Jamie – awesome. thanks for the heads up
Thanks for the work and upkeep on this interesting widget.
I’m having some trouble. The actual widget is not appearing in my Admin. I get the Widget Logic Options menu at the bottom of the page, but it’s not appearing in my widget list above. Since it’s in my admin page, I assume this has nothing to do with my theme. Any ideas?
[Update]
…clearly I should’ve explored more…I just noticed the fields added to all my widgets…sorry to waste your time.
Will widget-logic get an update for wordpress 3.0.1? That’s the version of wordpress I’m using, but the available download in the wordpress plug-in directory has the version for wordpress 2.9.2.
I can’t seem to get WL to work on my WP 3.0.1 at all. Even the simplest is_single() or !is_single() doesn’t work… my widgets appear no matter what. The WL version is 0.47. The wordpress plugin page says that it works with 3.0.1, with 7 people saying it works, but no luck here.
Perhaps it’s something with my theme? I’m open to suggestions. Thanks and I’m really looking forward to getting this valuable plugin working.
It might be your theme, yes. Try switching (briefly) to a standard theme – the new twenty10 and the old default themes work OK
Mitch, it works fine with 3.01, you’ll see the compatibility widget on http://wordpress.org/extend/plugins/widget-logic/ shows 100% of people say it works (well so far).
I haven’t had time to get into my code repository and update the ‘compatible up to’. I want to put in some small tweaks to the code too, so i’ll save it til i get that time.
@Alan – Thank you sir I got it working. Turns out I removed wp_head(). Once I put it back in it worked like a charm. Thanks again!
OH! Great
this arcticle is interesting. Do you agree with me?
I have a questions using the plug-in. The site I am working on have page and sub-pages structure as follow:
Products
- Overview (products/overview)
Solutions
- Overview (solutions/overview)
The problem those page have the same name and it can not be changed.
How can I get the plug-in to recognize the sub pages which have the same name (Overview) based on the main page without changing its name?
Not sure if you understand what I am trying to do any help would be greatly appropriated.
Thank you.
You could use the page’s numerical ID rather than the name/slug. One way that you can get the ID of a page by hovering over ‘edit’ in the list of pages and seeing what it says post= in the URL of the link
I’ve made that suggestion but that’s a no go. They want to keep the name because of site map and external links. So page id is not an option. I also mentioned to change the name to solutions_overview and products_overview and that’s not an solution either. :-(
is there a way to work around that?
i meant you can use the ID in the widget logic – there’s no reason not to use the ID there. I am assuming you want something like widget A to appear on Overview (the child of Products) and widget B to appear on Overview (the child of Solutions).
Then in widget A you use logic like is_page(105) and widget B you use logic like is_page(209)
This should have no bearing on site map or links.
Alan, it works. I thought I have to change Permalinks to display page ID in order for it to work. Thanks for your help.
I love this plug-in – it’s been a huge help, especially since some of the posts on my product review site are supposed to appear on ad-free pages and this widget gives me an easy way to categorize my posts so that will happen correctly. It’s been working perfectly for me, and still is with one small exception that I just noticed tonight.
I use “!in_category(‘BH Review’)” on the widgets that I don’t want to appear when the post is in that category, and that part is still working perfectly. But – all of a sudden on my main blog page, those widgets aren’t showing up either. Not having any of my ads on my main page is definitely a concern, so I’m hoping that you might have an idea of why it’s doing this all of a sudden?
My blog is http://www.momstakeonthings.com. The posts in the “BH Review” category are the ones where the ads don’t show up – they do show up (as they should) for single posts in every other category. But not on the main blog page… Help!! And thank you!
!in_category will also return true or false on any page that has a list of posts where the last post is in that category (sometimes it’s the last post, depending on how crazy the code in a theme is).
so you just need to tighten up your logic. something like
!(is_single() && in_category(‘BH Review’))
ie don’t show it when it’s a single post that’s in that category.
Widget Logic… I LOVE you :)
Aw lovely. Tell it to the totaliser: http://www.justgiving.com/widgetlogic_cancerresearchuk
Currently 200 quid, 40% of my target
But, THANK YOU :-D
Hi,
as it was said heaps before me, this plugin is awsome!
There are all sorts of complicated scenarios in the comments and I can’t work out what I need to do. I’m sure it’s been covered before but I can’t seem to find it – what do I do to apply widget logic to child pages as well as the parent one. (I guess I can just name all the pages separately but that means if a new child page is added later, it won’t be included automatically, right?) many-many thanks!
In the OTHER NOTES section of the WP repository is an example using get_post_ancestors that you can adapt that will cover children and even grandchildren posts (and so on, at least I believe). You need to add in an extra test to check if the current post is the parent too, so an || $post->ID==77, or something like that will do the trick.
good hostings
CHECK OUT singer/songwriter MICHIA MONIQUE ON http://www.reverbnation.com/michiamonique
Widget Logic is really nice!!!!
I’m building a website where I would like to put unique content on both sidebars on nearly every page.
Are my expectations unreasonable? Can Widget Logic pull this off?
Thank you in advance!!!