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, …
Author Archives: Douglas Radburn
How to check whether an element exists using jQuery
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 …
Using post items in Smarty from dynamic variable names
I’m building a site at the moment that uses the Smarty templating engine and I came across a snag today. The global “Smarty” variable includes a nice $Smarty.post reference where by you can get posted variables to display in your …
NoFollow links in comments within WordPress
I’ve recently added comments back into my blog. I know that Askimet will do the majority of the work in protecting me from SPAM, but I wanted to make sure I no-follow all the links too. I was interested to …
Only display add a comment if the post is recent in WordPress
I’ve always got quite a lot of comment spam on the blog, and this is mostly for older posts that I assume are already dead and wouldn’t be commented on. If you go back far enough, you find all sorts …