Due to updates, over time, that have been made to the site and the age of this article, this post may not display correctly. In particular images may be missing or product reviews display incorrectly.

If this is the case and you'd particularly like me to fix it, then please reach out to me on Twitter.

Many WordPress functions have a standard version which outputs the results directly and an additional version prefixed with get_ that returns the output – useful for adding to a string and manipulating before output.

One such exclusion is the_shortlink, which returns a short link to any page or post – there is no get_the_shortlink, so many people have to resort to just outputting the result in a FORM field for people to cut & paste.  However, here is a quick way to add the capability to your blog – simply add the following 5 lines to your theme’s function.php file…

Now you just need to call get_the_shortlink() from within your WordPress loop and it will return the shortlink URL.

Unlike the_shortlink it doesn’t accept any parameters, but this is a quick and simple solution.