Post link shortcode

While permalinks are supposed to remain unchanged indefinitely, you will need to change them on occasion. Regardless of the reason, you will probably end up rewriting the old URLs to keep them alive.

But what with all those links that you have used in your articles’ content? You have to change them too! With this simple plugin you can forget about the last step.

The plugin provides [post] shortcode that returns either an URL or anchor to a post.



The [post] shortcode takes one or more of the following attributes:

Setting anchor to “yes” will enable some additional attributes:

Example usage


When would you like to use it? When you want to link to the current post in the Loop.

I use it for tables of content, where I target specific sections using the hash sign (#) and I want it to work both on content page and on the archive pages.

See an example. (← this link is actually using [post id="104" anchor="yes" text="an example"]!)

[post id="42"]

Returns URL to post with ID equal to 42.


[post id="42" anchor="yes"]

Displays link to post with ID equal to 42. Anchor text will be the post title.

Example: Post link shortcode

[post id="42" anchor="yes" class="extra-link-class"]

Adds extra CSS class(es) to the anchor element.

[post id="42" anchor="yes" title="My post"]

Replaces default “Permalink to {{ POST_TITLE }}” anchor title (inside the tooltip when you hover over the link).

[post id="42" anchor="yes" title="See %s"]

More advanced usage of the above.

%s is bound to the post title, thus this is resulting in “See {{ POST_TITLE }}”

[post id="42" anchor="yes" title="The other post" text="click here"]

Allows you to set the anchor text as you like.

Example: Click here to see my GSoC introductory post.

PS Don’t use “click here” links – here’s why.

[post id="42" anchor="yes" text="Visit %s"]

More advanced usage of the above.

%s is bound to the post title, thus this is resulting in anchor text displayed as “Visit {{ POST_TITLE }}”

Read more…