music TV & Film games books food pubs science sport
Search Random post Register Login E-mail FT rss

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.

Alan

Freaky Trigger Theme

This was designed by Steve Mannion

Plugins FT uses

3,511 views |  

Responses

  1. STS on July 9th, 2008

    Hi,
    great plug-in! Can you help me?
    I try to hide the Categories Widget just from one page (id172)and show it on all other pages of the website.
    What is the code?
    Thanks !

  2. FT's Alan on July 9th, 2008

    look at the examples on http://wordpress.org/extend/plugins/widget-logic/other_notes/

  3. hershal on July 21st, 2008

    I was wondering how to get a widget to appear on multiple pages by indicating which specific page id’s i want the widget to appear on. how is this done?

  4. Philix on July 24th, 2008

    This is a great plug in :)

  5. FT's Alan on July 24th, 2008

    @ hershal

    you could use PHP’s logical OR operators like this

    is_page(’about-me’) || is_page(’42′) || is_page(’About Me And Joe’)

    or if you read http://codex.wordpress.org/Conditional_Tags you’ll see you can do the slightly more PHP-savvy but simpler

    is_page(array(42,’about-me’,'About Me And Joe’))

  6. Mieke Janssens on October 31st, 2008

    This is one of the most useful plugins installed on my blogs. :-D

    I have just one question:
    How can I exclude just one page and show the widget on all other pages (home, single, page)?

    I have looked at the examples on the suggested WP site, but still don’t have a clue what code to add to the widget logic box.

    Can you please help me out?

    Greetz!
    Mieke

  7. FT's admin on October 31st, 2008

    add a ! on the front, which means NOT in PHP

    !is_home()

    etc. i will add this to the plugins FAQ on the wordpress plugins site

  8. Robert Griffin on November 6th, 2008

    Alan,

    Love the widget Logic plug-in. Quick question though. I have been having problems with the speed of my site. I want to blame the host, they want to blame my plug-ins (I did go crazy with plug-ins when I started building my site). Since my site is so dynamic, at least the sidebar, I really can’t use a cache, or at least I don’t know how to use it with my sidebar and your plug-in.

    So 2 questions:
    1. Do conditional tags slow down the page loading by making additional calls to the database, or are conditional tags just reading the data que from the last query?

    2. Do you no of a way to be able to use your plug-in and WP Cache. WP Super Cache I don’t believe will help me since most of my users log in when they visit.

    thanks.

  9. FT's Alan on November 6th, 2008

    1 - i don’t believe so, no. if you look in wp-includes/query.php you’ll see a lot of the conditional tags code there. and they all do fairly simple manipulations of already established query results. is_home for instance is just

    global $wp_query; return $wp_query->is_home;

    and so on

    2 - the plugin doesn’t have any problem working with wp cache. unless you are using conditional tags that will produce different results over time.

  10. Thomas Clausen on November 23rd, 2008

    This looks like a fantastic plugin, can’t wait to try it out. It looks a bit like Ozh who sees ads, but your plugin seems more easy to use.

    Thanks a bunch.

  11. Tyrone on December 6th, 2008

    Hi there, is there a way to make a text/html widget on my blog appear only to me (as an admin) or to (logged in users) using this plugin?

  12. FT's Alan on December 6th, 2008

    You can use the current_user_can(’capability’) function, like this guy did:

    http://wordpress.org/support/topic/179656?replies=5

  13. matt on December 16th, 2008

    Is this working on 2.7? I keep getting an error when I update anything site wide.
    Warning: Cannot modify header information - headers already sent by (output started at /home/gvegason/public_html/krah/wp-content/themes/fresh-editorial/functions.php:15) in /home/gvegason/public_html/krah/wp-includes/pluggable.php on line 850

  14. FT's admin on December 16th, 2008

    it’s working on my 2.7 install yes. what happens when you switch to the standard theme? as it looks like something in the functions.php of your “fresh-editorial” theme is where the problem starts

  15. Lesson Plans for Life on December 23rd, 2008

    This is exactly what I was looking for, but am having some slight issues. If I do is_category(’fun’) the widget shows up when visiting page http://mydomain/category/fun/ but doesn’t show up on post in the category with urls http://mydomain/fun/post1

    Please help.

    Thanks,
    Eric

  16. FT's admin on December 23rd, 2008

    you want to use is_category for category pages and in_category for posts that are in specified categories

    the pages at WP, specifically http://codex.wordpress.org/Conditional_Tags are very useful on points like this

  17. Lesson Plans for Life on December 23rd, 2008

    Thanks for your reply! I should have done a little more research before asking.

  18. Andy on December 27th, 2008

    Hi-Thanks for all the useful information and the plugin–Andy

  19. Chanty on December 27th, 2008

    Hi Alan,

    I’m trying to get this to work with TTFTitles, but I keep getting errors. Since I’m still pretty much a n00b at php, could you help me out? I copied and pasted the codes (add_filter and the function) in my theme’s functions.php file, but I keep getting ‘unexpected’ errors. Here’s my code:

    add_filter('the_ttftext', 'ttftext_widget_title', [priority], 2);

    function ttftext_widget_title($content=”, $widget_id=”)
    { preg_match(”/]*>([^<]+)/”,$content, $matches))
    $heading=$matches[1];
    $insert_img=the_ttftext( $heading, false );
    $content=preg_replace(”/(]*>)[^<]+/”,”$1$insert_img”,$content,1);
    return $content;
    }

    Thanks in advance :)

  20. Chanty on December 27th, 2008

    Oh never mind, I fixed it myself :) There seemed to be an error in the filter for ttftitles, here’s the fixed version:

    function ttftext_widget_title($content='', $widget_id='')
    { preg_match("/]*>([^<]+)/”,$content, $matches);
    $heading=$matches[1];
    $insert_img=the_ttftext( $heading, false );
    $content=preg_replace(”/(]*>)[^<]+/”,”$1$insert_img”,$content,1);
    return $content;
    }

    $matches was closed with )) instead of );

    One more thing though: what is meant with [priority]? I removed it to get rid of the “unexpected ‘]’” error.

  21. FT's Alan on December 27th, 2008

    oops! i hadn’t noticed that extra ) in the TTFcode before - it should be a semi-colon instead. (which is otherwise missing!)

    [priority] is the optional parameter that you can give when you register with add_filter - it allows you to set order of filtering routines if needed.

    http://codex.wordpress.org/Function_Reference/add_filter

    thanks for pointing both these out - i will try to remember to update the official WP repository

  22. Chanty on December 28th, 2008

    Okay thanks! :)

  23. Illya on December 30th, 2008

    This is such a great plugin. I thought I would have to code a whole new sidebar for every page other than my index page and this theme has solved my problems effortlessly. Your work on this plugin is greatly appreciated at ilapko.com. Thanks!

  24. FT's admin on December 30th, 2008

    :-)

    remember you can still define different sidebars to be invoked by different template files (home.php, single.php. etc)

  25. Martha on December 31st, 2008

    I’m trying to figure out the right widget logic to use to display a widget only on a page or a sub-page of that page. I took a look at WP’s conditional tag information, and figured it is some variation upon

    ( is_page(’title’) || $post->post_parent == ‘xx’ )

    But nothing I try seems to work. Any tips?

  26. FT's admin on January 1st, 2009

    see my post here

    http://wordpress.org/support/topic/207694

  27. Martha on January 2nd, 2009

    Thank you, Alan! Awesome plugin and awesome help!

Comments: All, 1–25, 26–52.

Add a comment

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