Category: WordPress

Shorter Link: A rev=canonical WordPress plugin

Hot on the heels of my No DiggBar, I've created another extension for WordPress!

Shorter Links provides a <link> tag in the <head> section of your page with a shorter url and appropriate tags for use with the new revCanonical system. Further details can be found at, or

The link created looks like this:

By default, the shorter url is simply {your domain}/{post id}, but the plugin also creates a custom field called "Shorter link" once a post is saved, so that you can change the shorter link to a more memorable set of characters.

Rather handily, Simon Willison, has produced a bookmarklet called Shorten so you can find out if the page you are looking at has a shorter link or not.

As an example, my Zend Framework Tutorial page has a canonical URL of I have set up a Shorter Link of which will redirect to the correct page. The <link> tag for this is:
<link rev="canonical" rel="alternate shorter" href="" />

Why not download Shorter Links and have a play?

Update, the latest version uses rel="shorturl".

Digg bar blocker for WordPress

The DiggBar is a URL shortening service that puts your website within a frame on As a result, the user sees Digg's URL, rather than your URL in their address bar, no matter which page they navigate to on your site.

I don't particularly like this, so I've written a small plugin for WordPress that removes it. Go to the No DiggBar page to download it.

Tip of the hat to John Gruber for the idea.

Update: The No DiggBar plugin is now available from the WordPress Plugin Directory:

Fixing — in WordPress

One thing that I've noticed is that whenever I used — in a post, such as this one, WordPress converted the — to &emdash; which whilst very pretty doesn't work so well for people trying to understand command line switches to ./configure!

Today, I finally got around to poking into the WP source code to work out what was happening and I tracked it down to the wptexturize function in the wp-includes/functions-formatting.php file. Once I knew the name, it was trivial to google for a solution and I found Jason Litka's Disable wptexturize plugin. I couldn't find it through WordPress' new built-in plugin installer, so I installed it the old-fashioned way and now the code in my posts will make more sense!

post2cat doesn't exist after upgrading WordPress

Note to help anyone else who has the same problem!

If you are a "little behind" the times when you upgrade you WordPress installation, you may see errors like this:

WordPress database error: [Table 'xxx.wp_post2cat' doesn't exist]
SELECT cat_ID AS ID, MAX(post_modified) AS last_mod FROM wp_posts p
LEFT JOIN wp_post2cat pc ON p.ID = pc.post_id
LEFT JOIN wp_categories c ON pc.category_id = c.cat_ID
WHERE post_status = 'publish' GROUP BY cat_

This is because the tables used for storing categories has been changed and the old ones (wp_post2cat and friends) have been deleted and you have some old code in a plugin or your theme that uses it.

In my case it was this Google Sitemap Generator Plugin which was updated back when WordPress 2.1 was released, so the fault is clearly all mine! One thing that was interesting is that the plugin page within the WordPress admin system didn't tell me that I needed to upgrade that plugin, but it did tell me about others.

WordPress 2.0 Rewrite Rules

We recently upgraded my wife's blog from WordPress 1.5 to 2.0 and it broke the mod_rewrite rules used to support the legacy Movable Type urls. When she migrated from Movable Type to WordPress, we moved to /{year}/{month}/{day}/{slug} type urls from the default Movable Type rule of /archives/{id}.html. We read the manual at the time and put the following into the .htaccess file:

RewriteRule archives/0*(d+).html /index.php?p=$1
RewriteRule index.rdf /index.php?feed=rdf
RewriteRule index.rss /index.php?feed=rss
RewriteRule index.xml /index.php?feed=rss2

and all was well…

Then we upgraded to WordPress 2.0.

They stopped working because WordPress 2.0 does it's own mod_rewrite. I worked my way through the source code and modifed the core stuff and got it working. Then I started trying to find out how to do it properly without modifying the WordPress source code. I finally found a post on the support forums from someone trying to do something similar and modifed the solution to work for me:

Add the following to a file called functions.php in your theme directory:

and that's all there is to it.

Fairly obvious I would think if you know how WordPress works. There's probably a very handy article somewhere on detailling this, but I couldn't find it… probably didn't look hard enough!