As a developer, I’ve always found permalinks and directory structures between local, staging, and production environments to be a pain. Creating links within content requires either absolute (http://yourdomain.com/path/to/post/) or a non-domain-specific absolute (/install/directory/path/to/post) URLs.
This can prove to be a pain during the development or migration process. It can also make it annoying if you happen to change your permalink structure and have tons of posts.
Introducing dynamically inserted WordPress permalinks with The Permalinker
The Permalinker will allow you to use WordPress short codes to dynamically insert permalinks and permalink URLs into your posts via the content editor.
How it works:
When editing content, simply use the the [permalink] short code to insert a link:
[permalink]This is a link to the current post[/permalink]
Linking to a different post:
You can set the id attribute in the short code to point to a specific page/post:
[permalink id=23]A link to post 23[/permalink]
Supported anchor attributes:
Currently, the following attributes are supported in the [permalink] short code and will be added to the resulting anchor element: class, rel, and target.
[permalink id=23 class="my_class" rel="self" target="_blank"]Open post 23 in a new window[/permalink]
Want more control over your markup?
Using a non-terminating or empty [permalink] short code will simply output the permalink URL:
<a href="[permalink id=23]" class="thickbox" id="link_23">Another link to page/post 23</a>
There’s more: Dynamically grab your template directory
As a request from fellow WordPress designers and developers, I’ve included a [template_uri] short code as well, allowing you to quickly and dynamically get the full URL to your active template directory from the content editor:
<img src="[template_uri]/photos/yoda.gif" alt="A picture of Yoda!" />
Download Permalinker
You can learn more and download The Permalinker from the WordPress plugin repository.
Happy coding ;]
RSS feed for comments on this post. TrackBack URL
baron says…
Works great, thank you
andy says…
No problem, glad you found it useful!
sokai says…
Hi Andy!
Thanks for that simple and great working plugin!
But one Question:
Can you make the plugin work with the post-slug? (I hate looking for the ID if I have/can see the slug…)
Thanks a lot! – sofar|sokai
sokai says…
@slugs
…I found Post-to-Post Links II *thx*
andy says…
No worries, thanks for the suggestion. Perhaps I’ll add it as well. I agree the ID is not the easiest to find if you’re editing a different page.
I might also think about adding something to the post/edit page that allows you to browse ID’s or look them up… Matt Martz has a great plugin called Simply Show ID’s.