The Permalinker WordPress Plugin: Dynamic Permalinks

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 short code to insert a link:

[permalink]This is a link to the current post

Linking to a different post:

You can set the id attribute in the short code to point to a specific page/post:

A link to post 23

Supported anchor attributes:

Currently, the following attributes are supported in the 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

Want more control over your markup?

Using a non-terminating or empty https://theandystratton.com/2009/the-permalinker-wordpress-plugin-dynamic-permalinks short code will simply output the permalink URL:

<a href="https://theandystratton.com/?p=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 https://theandystratton.com/wp-content/themes/theandystratton 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="https://theandystratton.com/wp-content/themes/theandystratton/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 ;]

19 Comments

  1. baron says…

    Works great, thank you

  2. andy says…

    No problem, glad you found it useful!

  3. 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

  4. sokai says…

    @slugs
    …I found Post-to-Post Links II *thx*

  5. 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.

  6. Mike Lopez says…

    Simple and perfect! I like it and I use it!

  7. MisterE says…

    i like to use “named anchors”.
    For example i have one page with the next code:
    [permalink id="352#tips" rel="internal"]link to second page”[/permalink]
    But this does not work.

    The plugin does not receive the “#tips” part (with the “get_permalink” function, so i can’t change the code.
    Any thoughts?

  8. andy says…

    @MisterE GOOD IDEA. This was quick to implement. You can now add an additional shortcode attribute called “append”:

    [permalink id="352" append="#tips" rel="internal"]link to page[/permalink]
  9. andy says…

    Just posted the updated, may take up to 30 minutes to show in WP.org

  10. MisterE says…

    Thanks mate!. Just noticed the update en it works great!.
    Now i can link the “nice” way, like “http://localhost/blog/category/permalink2/#tips”

    With the normal “permalink” system i get “http://localhost/blog/category/permalink/index.php/permalink2#tips”

    Thanks again, when my site is online i will dedicate a page to the used components 🙂

  11. Dee says…

    Hi, i noticed the permalinker shortcode is showing up in my Facebook and LinkedIn social networks when i submit my feeds to it from my blog post? Anyway to prevent the actual code from showing up? It’s showing the entire code from the post, Example: [permalink]Keyword Link[/permalink]…

    Thanks.

  12. Dee says…

    Also, i think the ending results on a post or page should look like this once the shortcode is propagated:

    Keyword Link

    as appose to keeping it like this, in which now the public feeds and social sites are picking up the entire code on my page or post that shows up like this:

    ” [permalink]Keyword Link[/permalink], and so the new vintage slipper has now become ever so popular amongs…. ”

    Anyway to solve that issue to prevent the actual code from appearing in posts/pages? And what is happening now which is WORSE, the anchored text keywords ARE NOT being indexed by Google either!

    Thanks.

  13. Dee says…

    Sorry, the above sample post regarding the code turned into a link. It needs to look like this once propagated with the shortcode:

    “Keyword Link”

    Hopefully this does not link the code sample again? Thanks.

  14. andy says…

    Make sure you’re using the id attribute in the permalink. I have tested on the latest release of WP running TwentyEleven and just The Permalinker and have no issues.

    I’d try turning off other plugins or check your theme, it could be interfering with shortcode processing in feeds in some way.

  15. MisterE says…

    Andy, MisterE again.
    Another idea. Is it possible to add a flag (or empty) so it will replace the “number” with a complete URL using the posts title as anchor.

    so “[permalink id="666"][/permalink]” will be replace by “This is the post name“. In this case “This is the post name” would be the title of the post.

    Why would this be handy? I like to create a subset TOC on a post. So i can create a list of only “numbers” and i can later change the title of a post without changing content of the webpages.

  16. andy says…

    Give it 10-15 minutes then upgrade via your admin. Added ability to insert %post_title% into shortcode content and it will be the post’s current title, e.g.:

    [permalink id="666"]The post with the devil's number is named %post_title%[/permalink]

    Now, for your table of content’s, I’d just:

    Table of contents:
    [permalink id="123"]%post_title%[/permalink]
    [permalink id="124"]%post_title%[/permalink]
    [permalink id="125"]%post_title%[/permalink]
  17. How To Make Your WordPress Blog’s URL’s SEO-friendly | Bcat's Blog says…

    […] The Permalinker plugin might also help your SEO, this way you can place links to your posts like that: […]

  18. Dave says…

    Useful plugin, I have used it on a couple of my blogs. However I have noticed a possible bug. If you insert a bit of text into a blog on its own line, the editor will automatically wrap it in making it a paragraph. However if you put your [permalink] tag around it then the editor will not wrap it in

    Also, I think it would be useful for end users (and SEO) if the links had the title attribute of the inserted link set to the title of the page.

  19. Adalberto says…

    Aw, this was an extremely good post. Finding the time and actual effort to make
    a very good article… but what can I say… I put things off a lot and don’t manage to get anything done.

RSS feed for comments on this post. TrackBack URL

Leave a Comment

June 30, 2009

Filed in Plugins, Wordpress

There are 19 comments »


« Back to the Blog