Category “Geek”

Custom size featured image thumbnail with fallback in WordPress

Occasionally you may need to display featured images in sizes other than WordPress’ default thumbnail, medium and large sizes. That’s quite easily solved with the add_image_size() and the_post_thumbnail() functions. Unfortunately, there are still 2 problems to be solved:

  • Some posts may not have images at all, or the author forgets to attach a featured image
  • Previous posts don’t have featured images

Here’s a solution that 1) resizes the featured image to the right size, 2) uses the first image in the post if a featured image is not set and 3) falls back to a default image if none of the above are true. Read More »

More robust footer widget areas for Headway

I recently got an email from a reader who wanted to know how I implemented my footer widget areas, and seen some similar requests in the Headway forums. With Headway, you can flip your widget areas horizontally to make a widgetized footer but it works best when you only have 3-4 widgets in them. I wanted to have more flexibility and so I injected 3 widget areas into my footer.

Screenshot for posterity, if I ever re-design this blog. Click for full-size image.

I didn’t have time for a full tutorial but hopefully you’ll find these code snippets useful: custom_functions.php for Headway theme custom.css for fat footer widget areas

4 Awesome Tutorials on creating iframe Facebook tabs

Facebook recently revamped their Facebook Pages. One of the biggest effects of this is that you will no longer be able to create custom tabs with the Static FBML application by 11 March 2011. Luckily some people have quickly put out some excellent tutorials and resources to get everyone up to speed.

HyperArts has been publishing a series of tutorials on how to create iframe Facebook tabs.

Webdigi shares not only a tutorial, but downloadable examples as well!

Check these articles out and definitely bookmark them to bring yourself up to speed on creating iframe Facebook tabs.


Solved: Cufon text not refreshing on jQuery UI Tabs

Update: I no longer use Cufon in my projects and prefer @font-face. If you are struggling with Cufon it will actually be faster for you to replace it with @font-face than to figure out your Cufon problems. Start with this tutorial here: The Essential Guide to @font-face

Today I was working on a project that:

  1. Made use of jQuery UI Tabs through the WordPress Post Tabs plugin
  2. Uses custom fonts for the tabs via Cufon
  3. Requires tab font to change color when selected

Read More »

Bulletproof domain redirection for CPanel Add-On domains

Recently I helped my friend Beth Heavrin of Smart Green Tips to migrate her blog to a new domain name. Along the way I realized that the simple way of domain redirection doesn’t work as well for websites that are add-on domains in CPanel environments. This article shows you how to create bulletproof redirects that will work, even for add-on websites.

The Problem

CPanel site structure

In CPanel environments, you start off with a primary domain that resides in the public_html directory. When you add new site to your CPanel hosting, they are added as add-on domains whose root folder are subdirectories of public_html.

You end up with a directory structure in your web hosting account like the image on the right.

Simple .htaccess Redirects Don’t Work

For our example, let’s assume that the primary domain is and the new domain we want to redirect it to is To redirect to, you may have used this code in the .htaccess file for

# Redirect 301 /

Or, you may have used this code:

# RewriteRule ^(.*)$1 [R=301,L]

With the code above, will get redirected to But unfortunately visitors to will be wrongly redirected to Same for other add-on domains within the public_html directory.

This is because is a subdirectory of public_html. The 2 code snippets above redirect everything, including add-on domain subdirectories to Confused? Never mind! Just use the solution below.

The Solution

The solution is to check the hostname (URL) that the visitor is trying to visit before redirecting them. So, let’s update our .htaccess file to the following:

# Redirect to
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R=301,L]

#Redirect to
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R=301,L]

The first block of rules only redirects visitors to and the second block only redirects visitors to Visitors to or will not be redirected. Solved!

Simple form validation with FBJS on Facebook Page Tabs

Today I was working on a custom Facebook Page which included a sign up form. On the sign up form was a checkbox with an id of confirmoptin that needed to be checked before the form could be submitted: Read More »

Absolute basic Subversion for newbies with svnX

Update 11 Oct: Someone from the svnX team actually stopped by to add on to my post. See his comments below.

I’m not a programmer, but occasionally need to do programmer type things. One of these things is to use Subversion to keep collaborate on projects with other people. This is a tutorial on how to use Subversion on your Mac, for non-programmers like me. I’ll only cover the basics and what is absolutely necessary to get started with it. Ready? Let’s dive in. Read More »

Now I understand all the fuss about the Kindle

So I got an iPad. Don’t worry, I’ll spare you the fanboy gushing. I actually want to talk about Amazon’s Kindle service.

I’ve been wanting to stop buying paper books for a while now. I’ve also been buying ebooks in PDF and ePub format. Reading these ebooks have been less than ideal because I’ve had to read them on my computer (inconvenient) or on my iPhone (too difficult).

Kindle on iPad Read More »

Remove Headway update notifications

As you know I’m a big fan of the Headway WordPress theme. So much so I’ve been using it in client projects.

The one (small) drawback is that Headway puts a notice in the Dashboard every time there’s a new version. For certain clients I really don’t want to have anything to do with them after the project, so I would like to disable the notification. Here’s how.

In Headway’s custom_functions.php, simply add this line:

remove_action('admin_notices', 'headway_update_notice');

Solved. No more nagging client asking me what is this “Headway update thing”.

Theme Frameworks: A Glimpse Into The Future Of WordPress Themes [WordCamp Malaysia Presentation]

This was my presentation at the 1st ever WordCamp Malaysia where I was fortunate enough to be invited as a speaker.

Theme frameworks are the next evolution in WordPress themes. They’re still relatively new, so let’s start off by asking…

What is a Theme Framework?

Theme frameworks for WordPress can be a little confusing, and it doesn’t help that there are many blank themes that call themselves ‘theme frameworks’.

In my opinion, theme frameworks are a solid base that serves as a starting point for other projects. A defining characteristic of theme frameworks are theme hooks (actions & filters) and when developing for a theme framework, it feels a little like developing a plugin. Examples of theme frameworks are Thematic and Hybrid. Read More »