WordPressWordPress 4.4 eliminated the WordPress shortlink button. I found it to be a useful tool when making links for social media accounts. So how do you get the shortlink button back?

Previously I’d recommended the Shorter Links plugin.  I just discovered that this plugin causes bad links to appear in the headers of tag and category pages.  It gives a shortlink alright, the link just doesn’t work.  Visitors to your site will never see the broken link, but Google and sitemap software will find the broken links. For larger sites, this could result in hundreds of broken links appearing on sitemaps.

I found a better way to get the shortlink functionality back.  Add the following your theme’s functions.php file:

add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} );

It turns out that all the code to make the shortlinks is still in WordPress, it’s just no longer linked in on the WordPress post/page editor. The above code, adds it back in.

Leave a comment

Your email address will not be published. Required fields are marked *