WordPress Cross-References

Update: This plugin, which is no longer being developed, appears to be broken in WordPress 3.3, so I’ve removed it again. Fixing it would be way beyond my minimal coding skills.

I like to link to older posts when I’m writing new stuff. WordPress makes this really easy to do with a friendly linky box that lets you type in a search term to find the post you’re looking for:

This is pretty cool, but it would be nice if there was a way to see what posts are linking to the one you’re currently reading. There are a load of “related posts” plugins which work on various things like keywords, categories, the weather in Katmandu, the price of coal in Cleethorpes, and possibly some other things. That’s useful in a way, but not quite what I’m after.

Well, for a while I did use a Cross-references plugin. It worked by using a WordPress shortcode instead of a link, so you’d have [cref the-last-dragon The Last Dragon] in the editor, which would show up as a link in the post. And visitors to the post you linked to would see a list of linking posts at the end of the post, rather like this:

Links

Links

This was pretty good – it kept track of all the links in its own table in the WordPress database, and had a proper mechanism for removing itself if you decided you didn’t want to use it any more. But creating those links was a strictly manual process – you had to find the post you wanted to link to, copy its “slug” (the text at the end of the URL – the-last-dragon in the example I’ve used) and type or paste it in to the shortcode. Compared with the easy link insertion of the WordPress editor, this began to look like too much effort, so I stopped using the plugin, and converted all my [crefs] back into normal links.

But while I wasn’t paying attention, Wyatt Fang picked it up and added a useful feature – the ability to automatically create a link to an old post. It’s not quite as slick as the built-in WordPress link builder thingy, but it does the job.

Click on “Insert History Post Link”

Click the insert link

Click the insert link

Type in your search term – something that will be in the post you’re after, then click Submit

Type in your search term

Type in your search term

Find your post in the list of results and click on “Insert Post Link”

Select your post

Select your post

You can now type in the display text for the link. If you leave this blank, the plugin will use the post title, which may be just what you need. Either way, press insert.

Text to display

Text to display

Your shortcode has now been created

Shortcode
Shortcode

Issues

As you can see from the pictures, some of the buttons have text in what I guess is Chinese[1]. This doesn’t affect the operation of the plugin, and I don’t see it as a problem.

This worked perfectly on my test site, but at first the dialog box wouldn’t render properly here. This was caused by it trying and failing to produce a tag cloud at the bottom of the box. I had over 600 tags, and 5,000 posts, so it’s possible that this was just a bit too much for it. I’d already decided to dispense with tags anyway, so a removal operation made this plugin behave. Worth noting if you use tags and have a lot of them.

The plugin is in the WordPress repository, so you can either install it direct from your control panel (search for cross-reference, you should be able to identify it from the description), or download it in the old-fashioned way from the site:

WordPress › Cross-references « WordPress Plugins

Good, useful plugin. A bit of polish would be nice, but for now, it does exactly what I want.

[1] Corrections, as always, gratefully received