WordPress Dynamic Links
Posted on 4th Jul 2007
One of the problems I’ve found with WordPress (especially when creating a simplified setup for less techy people) is that there’s no separation between internal and external site links. Sure, you can make a link relative to the site root with a leading slash, but what happens when you change the structure of the site or move a page? Suddenly, all your links are dead. Surely a content management system should handle things like this?
Having hit this problem for a client site I’m working on, I decided to come up with a solution for it. In its current unpolished form, the Dynalinks plugin parses link tags as the page is constructed, so links will always be up to date. As for the unpolished part, it currently requires text to be inserted manually as so:
[link:14"]click here[/link]
This format will always provide a current link to the page with ID 14, no matter where it’s moved to in the site.
The plan is to extend this with a TinyMCE button to make inserting links easier without having to look up a page ID. Possibly down the line it may include dependency tracking, so a page can’t be deleted when it’s linked to, but maybe this is a bit overkill.
Update:
The script’s had a bit of an update so it now works with the URL ‘link:[page_id]‘, to fit in more with the editor and ease of use for non-techies. This also means it doesn’t need its own TinyMCE button.
Grab the plugin over at its project page.

Reader comments
Hey, this small little script looks like something I can use for one of my projects. Do you have it somewhere available?
Mathijs
Leave a comment
Your email address will not be shown on the page. HTML is disabled, but URLs will be converted to links.