Loading jQuery in the footer

Loading Javascript in the footer has many benefits such as speed, you give priority to visual elements of your site. Your site will render for the visitor, then it will load the Javascript.

By loading Javascript at the end of the page, it immediately has access to the whole DOM, no waiting. If you are really clever, you can do away with your document.ready() function too

With WordPress its really easy to move the Javascript into the footer.

Use the following in your functions.php file

wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', false, false, true);

Continue reading “Loading jQuery in the footer”

[Snippet] Adding your custom taxonomy to post/page list in WordPress

Custom Taxonomies are amazing for organising your post data. Here’s a simple way of showing your custom taxonomies on the post/page list in wp-admin.

In the image below you can see we are now showing the custom taxo Brand in the post list.


Here’s how I did it Continue reading “[Snippet] Adding your custom taxonomy to post/page list in WordPress”

Automatic Photo Blogging with WordPress

My latest WordPress challenge was to automate a photo blog site. The photo blog post content would just consist of a title and a featured image. No content. As per normal photo blog style sites.

This solution takes an image at random from a folder and posts it in WordPress. It relies on a healthy collection of images to work from.

Really simply, it needed to select a photo at random and post it. Sounds easy, until to you start to code it.

Here’s my solution.

Continue reading “Automatic Photo Blogging with WordPress”

Using Persistent Cache in WordPress (with APC)

Ever since WordPress 2.5, the WP Cache functions haven’t been persistent, so the cached objects are only available for the page load (or script run). This means that data stored in the cache resides in memory only and only for the duration of the request.

Upto version 2.5 we could have simply added define(‘WP_CACHE’, true) to the wp-config.php and we got persistent cache features. This is no longer the case and isn’t really very well documented.

The later versions need a Persistent Cache Plugin. I’m not a fan of some of the larger caching plugins like W3 Total Cache or WP Super Cache as they tend to add complexity and can cause other problems. Besides, as developers, we’re better off writing the code ourselves.

Before going any furuther its probably worth pointing out WordPress has two persistent caching methods.

The first method is the WP Transients API,

The second method is extending the existing WP Object Cache that is currently throughout your WordPress site already.

  • Extending this object is much more flexible
  • Can extend into APC, memcache or similar
  • Provides a fast cache for basic WordPress functions even before you write your own code

Continue reading “Using Persistent Cache in WordPress (with APC)”

WordPress/Shopp Shipping Calculator/Options Access-Control-Allow-Origin Error

I’ve recently been debugging a customer’s WordPress/Shopp store. When the customer set the Cart & Checkout to be served over SSL  the shipping calculator failed.

Serving Cart / Checkout / My Account pages over SSL is not built into Shopp for some reason. I have a post on this –  SSL/HTTPS for Shopp pages or checkout process only. If you use a shipping calculator, or offer different shipping methods this will fail. Continue reading “WordPress/Shopp Shipping Calculator/Options Access-Control-Allow-Origin Error”

[Snippet] Programmatically add a WordPress User

Here’s how I would programmatically add a WordPress User

$user_name ='kieran';
$user_email = 'kieran@bl0ke.org';
$user_id = username_exists( $user_name );
if ( !$user_id ) {
$random_password = wp_generate_password( 12, false );
$user_id = wp_create_user( $user_name, $random_password, $user_email );
} else {
$random_password = __('User already exists. Password inherited.');

Using custom CSS in cForms

Pretty much every WordPress installation I’ve done in the last few years has got cForms installed. Its one of the must have plugins.

Many people are unaware of the custom CSS options available in cForms. Ever edited a default style and lost it during an upgrade? Annoying isn’t it?

Here’s how you make a custom, upgrade proof CSS skin for your cForms. Continue reading “Using custom CSS in cForms”

Debugging WordPress

Debugging WordPress is actually quite simple. Stop yourself going grey and or bald.

In your wp-config.php, replace

define('WP_DEBUG', false);


define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

This will turn on debugging and debug events will be wrote to wp-content/wp-debug.log. Bonzer!

Optionally, you can add, to turn off on screen error reporting if your php.ini isn’t already doing so.

define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);


WordPress function remove_menu_page

WordPress is now being used more and more for a full site CMS and the “Links” or “Blog Roll” is pretty much redundant now. People seem to be going to great lengths to remove this from the WP admin page. I’ve seen people use Role Manager plugins, wierdo so called “CMS” plugins and plugins specific to removing the “Links” link. Continue reading “WordPress function remove_menu_page”