Category Archives: Plugins

Widget Logic

Widget Logic control field
Widget Logic control field added to every widget

The popular plugin Widget Logic allows custom control over all of your sidebar widgets.  This allows you to pick and choose which pages or posts will have the widget.

Ordinarily, when you place a widget in a a sidebar under Appearance -> Widgets that widget will appear on all pages/posts.

With this powerful plugin, a layperson has complete control over when to display a widget.

A new control field is added to every widget (see picture).  Don’t be intimidated by the php code in this field.  The basics are very straightforward. If you only want the “recent posts” widget to display on the blog page for instance, add “is_home()” to the control field.


  • is_home() — just the main blog page
  • is_page('about')just the page named about

  • is_user_logged_in() — shown when a user is logged in
  • is_category(array(5,9,10,11)) — category page of one of the given category IDs
  • is_single() && in_category('baked-goods') — single post that’s in the category with this slug
  • current_user_can('level_10') — admin only widget
  • strpos($_SERVER['HTTP_REFERER'], "")!=false — widget to show when clicked through from a google search
  • is_category() && in_array($cat, get_term_children( 5, 'category')) — category page that’s a descendent of category 5
  • global $post; return (in_array(77,get_post_ancestors($post))); — WP page that is a child of page 77
  • global $post; return (is_page('home') || ($post->post_parent=="13")); — home page OR the page that’s a child of page 13

Note the extra ‘;’ on the end where there is an explicit ‘return’.

Basic Logic

These logic operators can be used in combination with the code above.

  • ! (NOT) to reverse the logic, eg !is_home() is TRUE when this is NOT the home page.
  • || (OR) to combine conditions. X OR Y is TRUE when either X is true or Y is true.
  • && (AND) to make conditions more specific. X AND Y is TRUE when both X is true and Y is true.

example: !is_user_logged_in() — shown when a user is not logged in

A full list of WordPress built in conditional tags that can be used in the Widget Logic control field can be found here.

Writing Logic Code

The text in the ‘Widget logic’ field can be full PHP code and should return ‘true’ when you need the widget to appear. If there is no ‘return’ in the text, an implicit ‘return’ is added to the start and a ‘;’ is added on the end. (This is just to make single statements like is_home() more convenient.)

Very Advanced

The ‘widget_content’ filter

When this option is active (tick the option tickbox at the foot of the widget admin page) you can modify the text displayed by ANY widget from your own theme’s functions.php file. Hook into the filter with:

add_filter('widget_content', 'your_filter_function', [priority], 2);

where [priority] is the optional priority parameter for the add_filter function. The filter function can take a second parameter (if you provide that last parameter ‘2’) like this:

function your_filter_function($content='', $widget_id='')

The second parameter ($widget_id) can be used to target specific widgets if needed.

A WordPress filter function ‘takes as input the unmodified data, and returns modified data’ which means that widget_content filters are provided with the raw HTML output by the widget, and you are then free to return something else entirely:

Example filters

add_filter('widget_content', 'basic_widget_content_filter'); function basic_widget_content_filter($content='') { return $content."<PRE>THIS APPEARS AFTER EVERY WIDGET</PRE>"; }

The motivation behind this filter is to to render all widget titles with the excellent ttftitles plugin like this:

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

People often ask for a way to give widgets alternating styles. This filter inserts widget_style_a/widget_style_b into the text usually found in a widget’s main definition:

add_filter('widget_content', 'make_alternating_widget_styles'); function make_alternating_widget_styles($content='') { global $wl_make_alt_ws; $wl_make_alt_ws=($wl_make_alt_ws=="style_a")?"style_b":"style_a"; return preg_replace('/(class="widget )/', "$1 widget_${wl_make_alt_ws} ", $content); }

Share on Facebook

Updating Plugins

Updating WordPress PluginsUpdating WordPress plugin using subversion.  The plugin/theme author will need to grant you access.

Plugin author – add contributor as a “Committer”

  1. Goto plugins administration page
  2. Add Committer username

For contributors

  1. Install client software
  2. Create a folder on local PC for code
  3. right-click folder -> SVN Checkout
  4. URL of repository
  5. make changes to the trunk (don’t chg “stable tag” in readme until ready to release)
  6. commit (this does not publish, just makes the file available in the repository)
  7. when ready to release next version
    1. update version in php file
    2. update “stable tag” in readme file
    3. right-click in folder -> TortoiseSVN -> Branch/tag
    4. right-click SVNcommit

Related Reading

Share on Facebook

WP ChatBlazer released

WP ChatBlazer Plugin
WP ChatBlazer Plugin


I just published my first WordPress Plugin, WP ChatBlazer.  It embeds a cool Chatblazer chat application on WordPress website.

Look for it in the WordPress Plugin Directory


Share on Facebook

ICS Calendar plugins

Calendar of Events is a common requirement for websites.  There are countless ways to implement a calendar.

Here are a couple of tutorials that show how to integrate a Google Calendar into your website.  Use of Google Calendar makes it easy to streamline the process of assigning and re-assigning calendar managers to folks without having to train on WordPress or website coding.

ICS Calendar plugin tutorial

Stout Google Calendar plugin tutorial

Share on Facebook

WP CAPTCHA Free – WP Plugin

Today I installed the WP Captcha-Free plugin on to while I was at solving the problem with a bot attack.  I don’t know how t generate a bot comment, so not sure how to test it.   But, can’t hurt to have this protection since the bots found this site.  I will add it to too since that site gets comments from bots pretty regularly.

WordPress › WordPress Plugins
WP Captcha-Free… automated comment spam without resorting to CAPTCHAs. It does so by validating a … are human without inconviencing them with CAPTCHAs, challenge questions, etc. The plugin is … was submitted. I would suggest using WP Captcha-Free in conjunction with Akismet … Version 0.7Updated 2009-7-4Downloads 30,643Average Rating

Share on Facebook

Adding CAPTCHA field to Contact Form got slammed by bots yesterday.  The bots found the contact form provided by the Contact Form 7 plug-in.  Luckily there’s a companion plug-in Really Simple CAPTCHA that allows adding captcha field to forms.  CAPTCHA modules are as annoying as hell for the end user, but some people just spoil it for everyone.

WordPress › WordPress Plugins
Really Simple CAPTCHA… other variables. Generate a random word for CAPTCHA. $word = $captcha_instance->generate_random_word(); Generate an image … please submit them . really-simple-captcha screenshot 1 screenshot-1.png 1.1
The required … Version 1.1
Updated 2009-11-10
Downloads 88,782Average Rating

Screenshot of CAPTCHA on a Contact Form
Screenshot of CAPTCHA on a Contact Form

Once this plug-in is installed and activated, use Contact Form 7’s form editor to add a CAPTCHA field.  It turns out this CAPTCHA isn’t as hard to read as some I’ve seen.  We’ll see if it actually does the trick warding off those pesky bots that wander the internet and fill out forms with random garbage.

Share on Facebook

Ozh’ Admin Drop Down Menu – WP Plugin

Today I installed a new WP admin tool on and   I had been using WP-Admin but noticed 300K people are using this one and I see why. Checkout the screenshot. See the Settings menu drop down.

Oz'h Admin Drop Down Menu

WordPress › WordPress Plugins Ozh’ Admin Drop Down Menu… productive will love it : all admin links available in a neat horizontal … documentation, usage and tips ozh-admin-drop-down-menu screenshot 1 Drop … icons, configurable color scheme ozh-admin-drop-down-menu screenshot 2 Normal … Version 3.3.5Updated 2009-11-8Downloads 202,773Average Rating

Share on Facebook

WordPress Plugins I want to try

Post Thumb Revisited

Post-Thumb Revisited automatically creates and displays thumbnails for posts. Numerous functions and options to modify themes are available. The plugin scan posts for images. Then, it can do the following…

This one could just make for a cooler way of browsing through topics.  Might try it out on the family site once we have a good amount of content up there.

updated 2015 – this is now standard functionality in WP

WordPress Video Plugin

… A filter for WordPress that displays videos from, youtube, google video, Brightcove, Aniboom,, MyspaceTV, Yahoo! Video, Veoh, W A filter …

May replace the one I’m using with this.  At the moment I can’t remember where I got the one I’m using called video-plugin by daburna.  The contribution site listed in the readme.txt is in German.

2015 update – this is now provided by Jetpack

Custom widgets

With this plugin, you can configure where widgets are displayed on a per post or per WP Template(Using conditional Tags) basis. The Ultimate WordPress Widget configuration plugin! This plugin enables you to

I’m hoping this one will help when I get ’round to syndicating some of the various Bluegrass sites onto the MRBA blog.  I figured out how to do this with the widget but didn’t want it in the right-hand column on every page.  My idea was to have instrument specific pages that would have syncidations from specific sites like Reso-hangout for the dobro section and mando-hangout for mando.  This will have to wait until I’ve finished getting the basics working on the site for the scheduled go-live date of Jan 1

2015 update – this is now standard functionality in WP (visibility)

Share on Facebook

WordPress plugins

WordPress plugins give you a super easy way of adding functionality to your WordPress site. There are hundreds (maybe thousands) available that do just about anything you could dream of wanting on your site. Browsing the directory is also a great way of getting ideas for things to add to your site.

Here are some that I use and my experience with them:

  • Members Only – At first, the redirect after log in didn’t work (404 error). That was because I use sub-domains and had not set the URL(s) in Settings to match the sub-domain name. Works great now on our private family website.
  • BM Custom Login – Brand site with custom log in page. Comes with .psd template to help you design your new log in box.  Used this on our family website.
  • Akismet – Comments spam filter.  Guess it works.
  • Contact Form 7  – it’s simple and works great
  • WP e-Commerce – trying this out (verdicts still out)
  • Google XML Sitemaps Generator (used for, Google, MSN Search and YAHOO)

Several of the Plugins that I’ve tried don’t seem to work in Firefox so I’m avoiding them.


Related Links:

WordPress plugin repository

WordPress database

Share on Facebook