How to publicly show wp.me shortlinks automatically on every post?

WordPress offers wp.me shortlinks on every post for you to share quickly on Twitter, Facebook and other social networks.  But by default this wp.me URL is not publicly available/displayed on each post.

Unless you go to the edit post screen and get the link from there.  Getting wp.me shortlinks from edit post screen limits its use for public.  What if you want everyone visiting your blog to show and use this link for sharing your post instead of using bit.ly and other URL shorteners.

It’s actually a simple hack to publicly show wp.me shortlinks automatically on each post.  Let’s see how:

Before we start, please make sure you have “Pretty links” enabled on your blog under Jetpack.  That means you should be using Jetpack for WordPress on your blog domain.  If you do, keep reading…

How to show wp.me shortlinks on every post?

  1. Login to your blog Dashboard.
  2. Go to Appearance – Editor.  That should take you to the current installed ‘theme editor’.
  3. Click on “loop.php” on the right side and look for “post-meta”.
  4. As soon as you find that area of the code, add the following to this code as explained below:
    <?php the_shortlink( $text, $title, $before, $after ); ?>

    Explanation:  The first parameter, $text, can be anything you want to display to the public.  The next value, $title, is for the tool tip that will appear when they hover the mouse. Leave it blank, because the default is the post’s title. The last two, $before and $after are for the things you would like to display before and after the short link.

  5. Based on the above, here is how my code looks like:
    <p class="post-meta">
    <?>php the_shortlink('Permalink','',' | ',','); ?>
    </p>
  6. And if you want to display this link as I have on my post pages, add the following to “Single.php”  wherever you want the link to appear:

<!--wp.me Short URL -->
<h4>Short URL - <?php echo wp_get_shortlink(); ?></h4>
<!--/wp.me Short URL -->

Because of what I did in Step 5, the wp.me shortlink is shown on Homepage and on each post page where I show the post meta – Author, Date, Tags, Categories etc.

 wp.me shortlink

And as a result of Step 6, the wp.me shortlinks are shown on each post as well:

wp.me shortlink

Short URL Display on Individual Post

What do you think?  Isn’t it nice that you could actually show this hidden wp.me shortlink to public?  Instead of creating a new bit.ly link every time, you also have access to this link.   Feel free to share this post with your other blogger friends and let me know in comments if this post was helpful to you.