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

wow, look at all of them. FT salutes you


in • 124,691 views

Comments All, 1–25, 26–50, 51–75, 76–100, 101–125, 126–150, 151–175, 176–200, 201–225, 226–250, 251–275, 276–300, 301–325, 326–350, 351–375, 376–400, 401–425, 426–469.

  1. Steve Ovens on 3 August 2010 #

    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

  2. Jamie Northrup on 4 August 2010 #

    Great WordPress Plug-In, will be featured as the Plug-In of the day on our website on August 18th.

    Thanks,
    Jamie

  3. admin on 4 August 2010 #

    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

  4. Adam Roberts on 5 August 2010 #

    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.

  5. Mitch on 10 August 2010 #

    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.

  6. JC on 11 August 2010 #

    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.

  7. Alan not logged in on 11 August 2010 #

    It might be your theme, yes. Try switching (briefly) to a standard theme – the new twenty10 and the old default themes work OK

  8. Alan not logged in on 11 August 2010 #

    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.

  9. JC on 11 August 2010 #

    @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!

  10. gourmetfoodss on 14 August 2010 #

    OH! Great

    this arcticle is interesting. Do you agree with me?

  11. Sion on 17 August 2010 #

    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.

  12. admin on 17 August 2010 #

    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

  13. Sion on 18 August 2010 #

    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. :-(

  14. Sion on 18 August 2010 #

    is there a way to work around that?

  15. Alan not logged in on 18 August 2010 #

    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.

  16. Sion on 18 August 2010 #

    Alan, it works. I thought I have to change Permalinks to display page ID in order for it to work. Thanks for your help.

  17. Deb - Mom of 3 Girls on 16 September 2010 #

    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!

  18. Alan not logged in on 16 September 2010 #

    !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.

  19. Stephen Johnson on 5 October 2010 #

    Widget Logic… I LOVE you :)

  20. Alan not logged in on 6 October 2010 #

    Aw lovely. Tell it to the totaliser: http://www.justgiving.com/widgetlogic_cancerresearchuk

    Currently 200 quid, 40% of my target

    But, THANK YOU :-D

  21. Ildi on 19 October 2010 #

    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!

  22. Alan on 19 October 2010 #

    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.

  23. B on 11 November 2010 #

    good hostings

  24. Michia Monique on 11 November 2010 #

    CHECK OUT singer/songwriter MICHIA MONIQUE ON http://www.reverbnation.com/michiamonique

  25. Michael on 29 November 2010 #

    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!!!

Back up to post. More comments: All, 1–25, 26–50, 51–75, 76–100, 101–125, 126–150, 151–175, 176–200, 201–225, 226–250, 251–275, 276–300, 301–325, 326–350, 351–375, 376–400, 401–425, 426–469.

Add your comment

(Register first to guarantee your comments don't get marked as spam)