Cross Referencing Posts

By default if you want to link to another post in your WordPress site you have to use an absolute URL. So for example, to link to my post on web development screencasts, I need to add a hyperlink with the full URL:

http://blog.praj.com.au/posts/web-development-screencasts/.

This isn’t ideal:

  • First, it takes time to find the URL and add it
  • Second, if your site structure changes, your internal links will break

Luckily there’s a really nifty plugin available called Cross-References which solves this problem. It allows you to embed a cross reference into your post based on the post ID or slug. For example, the slug for the web development screencasts post is web-development-screencasts. So I can write the following within my post and it will convert it to a URL:

[ cref web-development-screencasts Web Development Screencasts ]

Note you don’t put spaces between the [ & ] brackets. They are shown in this example to prevent the example being converted into a link. This is how the link HTML looks when applied:

Web Development Screencasts

Another nifty feature is that cross references can add related posts at the end of any articles that have been cross referenced. This is enabled in the Cross-references plugin settings – make sure you change from id to slug if you are using a slug and don’t forget to press the save button. Take a look at the Web Development Screencasts post to see the related posts functionality in action – it will have a link back to this article which references it.

March 21, 2010 | In Web Development | No Comments

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment