BlogThemes

How to Display WordPress Shortlinks in Your Theme

Have you ever ever seen websites which have a bit enter discipline on the backside of their publish with a brief hyperlink to their article? Nicely often that shortlink is coming from the WordPress get_shortlink filter. On this article, we’ll present you ways you should utilize the get_shortlink codes to show a bit enter field in your publish. It can additionally enable your consumer to pick the shortlink on one click on which makes it simple for them to repeat and paste it.

All it’s a must to do is put this code someplace within the loop (often in single.php) file.

1
2
3
4
5
<?php if (function_exists('wp_get_shortlink')) { ?>
<div><span class="post-shortlink">Shortlink:
<enter sort='textual content' worth='<?php echo wp_get_shortlink(get_the_ID()); ?>' onclick='this.focus(); this.choose();' />
</span></div>
<?php } ?>

This can carry you a similar shortlink that you just see while you click on the Get Shortlink Button under your publish title.

Get Shortlinks in WordPress Theme

By default it’s yoursite.com/?p=1082 or one thing comparable. However that may be changed with different companies by utilizing any shortlink plugin that makes use of the “get_shortlink” filter to override the shortlink correctly like WordPress.com Stats for (wp.me) or WP Bitly for (Bit.ly or Bit.ly PRO)

After you have the code added in your theme, the preview would seem like this:

Code Preview in WordPress Theme

Download The WPSaviour App Now

Related posts
Beginner’s GuideBest WordPress PluginsBlog

9 Best Social Proof Plugins for WordPress & WooCommerce (2020)

BlogTutorials

How To Add Pagination To Your WordPress Theme

Tips

9 Things You Should Consider while Choosing a WordPress Theme

Tips

The Dilemma Between “Pretty” And User Friendly: How To Pick The Perfect WordPress Theme

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee
Euro