Author Archives: Douglas Radburn


Getting a list of blog posts in WordPress

Quite often recently when building WordPress themes for smaller sites (ones that have a brochure feel, but have a blog section), the design has included an area on the frontpage, or footer that shows a list of the latest blog …

Excluding directories when tar/gzipping

You can exclude directories when tar/gzipping folders in the following way: 1 2 3 tar -cvf httpdocs_bk.tar.gz /var/www/vhosts/domain.com/site –exclude "/var/www/vhosts/domain.com/site/excludeddir1" –exclude "/var/www/vhosts/domain.com/site/excludeddir2" Tweet This Post

Delay link event with AJAX jQuery

I’ve been working on a script recently where it would add warnings when a user clicked on certain URLs. I attached an event to a link like so (simplified): 1 2 3 4 5 $(‘a’).each(function(){ $(this).click(function(event){ addWarningToURL($(this).attr(‘href’)); }); }); I …

How to check whether an element exists using jQuery

There are some subtleties to jQuery that still confuse me, compared to how traditional JavaScript acts at least. With traditional JavaScript, you could check for “an element”. The simplest example would be getting an element by ID. Say for example, …

Opening links in a new window with jQuery

With the advent of XHTML Strict 1, you can no longer use target=”_blank” on an A tag in your code. The only solution for this is to use Javascript to action a new window / tab to be opened. The …

Another take on feed caching with WordPress

Since version 2.8, WordPress has included the SimplePie class at it’s core. For a while, SimplePie wasn’t being maintained by the developer, but the WordPress team took over and kept the class alive. With the class now being at the …

Using shortcodes in a template file in WordPress

I’m using Contact Form 7 on a website I’m building. Currently, Contact Form 7 uses shortcodes, meaning you can drop forms into posts. Something like   You can’t use shortcodes in template files, because WordPress doesn’t parse them the same …

Replacing multiple occurrences of a string in JS

I’m a little disappointed JQuery doesn’t have something uber fancy for this. Something that always catches me out is when trying to replace occurrences of a string, it only replaces the first if you use the default “.replace” method. str …

Geolocation with Google Maps

A while back I wrote a proof of concept for a site which, at its core, allowed people to pick a location on a map. It used the long/lat for that location to see how close you were to another …

Controlling layout with Featured Image sizes in WordPress

Recently, I was working with a WordPress theme that includes a “featured image” (added recently to WordPress). Instead of just displaying it on the frontend, I wanted to know how big it was so that I could add a css …