Documentation for the Textpattern plugin smd_short_url by Stef Dawson follows this short message from our sponsor ;-)
If you like my code and it soothes an otherwise unscratchable itch, feel free to show your appreciation with something from my UK Amazon wish list (or US) or donate to the Stef Dawson community coding pot, either via paypal.me/stefdawson by following the Donate button below to PayPal. Thanks!
Requires TXP 4.2.0.
Allow visitors to use short URLs comprising just site.com/article_ID, which will redirect to the real article.
Install. Activate. Done.
If you wish to add the canonical
<link> tag to your document that defines the article’s short URL for search engines then put
<txp:smd_canonical /> somewhere in your
<head> section. Remember it must go inside a
<txp:if_individual_article> conditional or it will throw an error.
The tag takes one optional attribute:
type can either be
link (the default) to output the full formatted canonical link tag, or
url to output the raw URL so you may use it in your own manner.
Thanks to wet for a large chunk of the code.
- 16 Jun 09 | 0.1 | Initial release
- 23 Jun 09 | 0.11 | Fixed callback point to play nicely with gbp_permanent_links (thanks pieman/graeme)
- 19 Jul 09 | 0.2 | Requires TXP 4.2.0 ; changed callback to txp_die and status code to 301 (thanks wet)
- 17 Sep 09 | 0.21 | Kludge to force HTML redirect if
header()fails for whatever reason (thanks the blue dragon)
If you’d rather frolic in the raw code halls, you’ll need to step into the view source page.
If, for some inexplicable reason, you need an ancient version of a plugin, it can probably be found on the plugin archive page.
If you’re feeling brave, or fancy going bareback, you can test out some of my beta code. It can be found on the plugin beta page.