longUrl

cfml.us WordPress Plugin

I’m a WordPress user, and have been for as many years as I’ve been developing (which is a lot, now that I think about it..man, I feel old sometimes). However, I’m primarily a ColdFusion developer, and always want to share the CF love whenever possible.

I developed a simple WordPress plugin that uses the cfml.us URL shortening service written by Tim Cunningham which will automatically create and store a shortened URL for your pages and posts.

How to..

Installation of the plugin is simple. Download the .zip file and upload it into your WordPress plugin repository (either FTP or via the admin interface) and activate it.

There are two methods of use.

The first is as a shortcode, which can be used within the content editor for any page or post.

The default shortcode is as follows:

This will use the default title / lead text and output the link like so:

We can override this a little and specify a different lead text (or nothing at all) and provide a class name for the link using the inline attributes:

The second option is to set a function directly within your template code to output the link wherever you want to:

Saved and Stored

When a new URL is generated for the parent page using the plugin, the shortened URL is saved as a custom post meta value. This removes any possible issues with duplicate URLs being generated for the same long URL, and it only needs to be created once.

Grab it

The code is available to download from Github now: https://github.com/coldfumonkeh/cfml.us-Wordpress-plugin

If you’re a Mac user and have Alfred App installed (with powerpack) you can also use my cfml.us extension there to create shortened URLs, copied directly to your clipboard.