Add a shortlink to the end of your WordPress posts

Once again, that Andy Mabbett has given me the reason to knock out a quick WordPress plugin.

This one prints out a “Shortlink for this post” link (see screenshot) to the end of all your posts. It uses WordPress’ built in shortlink feature which doesn’t always produce very short URLs so you’ll want to use one of the shortener plugins alongside it.

You should also consider activating this shortlink plugin too which adds machine-readable references to the shortlink in the code for each page.

Download the plugin here and then,

  1. Unzip and upload add-shortlink-to-posts.php to your /wp-content/plugins directory
  2. Login to your dashboard
  3. Go to Plugins and activate the Add Shortlink to Posts plugin
  4. Check it works okay

WARNING: This has not been tested extensively and may well cause a black hole to open up and swallow your dog. Ensure you have a back up before trying out any untested plugins like this one.

If you do get it working, I’d appreciate you letting me know in the comments including what version of WordPress you are using and whether it’s a Multisite or not.


Posted

in

by

Comments

8 responses to “Add a shortlink to the end of your WordPress posts”

  1. Andy Mabbett Avatar

    Thank you. Working well on http://pigsonthewing.org.uk which is a single-site install of the latest version, v3.1.1

    I notice, though, that the link is added within and at the end of – the “.entry-content” div. Could it perhaps go in the “entry-utility” div, or is that skin-dependent?

    The pedant in me would like you to add rel=”shortlink”, too, please 😉

  2. Philip John Avatar

    rel=”shortlink” added, just download it again 🙂

    The entry-utility bit is theme specific. This plugin hooks into “the_content” – i.e. it does the machine equivalent of editing your post and adding the link using the visual editor which WP then puts into that div.

    Cheers!

  3. Andy Mabbett Avatar

    Thank you! That’s working, too.

  4. Andy Mabbett Avatar

    I had to disable the plug-in as it was inserting a duplicate of the post’s title at top of content (observed in preview).

  5. Ian Douglas Avatar
    Ian Douglas

    I really like this, and thank you for developing it, but I wonder if the short code could appear in a small text box: something that one would obviously cut and paste. As it is, people might click the link instead of copying and pasting the link reference. Clicking the link takes you exactly to the long form URL words-based permalinks are good for

  6. Philip John Avatar

    I’ve just put this on WordPress.org at last: http://wordpress.org/extend/plugins/add-shortlink-to-posts/

    A couple of improvements. If you have any issues please post a new thread at http://wordpress.org/tags/add-shortlink-to-posts?forum_id=10 so I can best deal with it.

    Thanks!

  7. Andy Mabbett Avatar

    Still inserting a duplicate of the post’s title at top of content 🙁

  8. Philip John Avatar

    Thanks Andy. I’ve got the notification of your WP.org post so I’ll look at this later today and get back to you there 🙂

Leave a Reply

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