How to Display WordPress Shortlinks in Your Theme

Like Tweet Pin it Share Share Email

Have you ever ever seen websites which have somewhat enter subject on the backside of their put up with a brief hyperlink to their article? Properly normally 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 somewhat enter field in your put up. It’s going to 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 important to do is put this code someplace within the loop (normally in single.php) file.

<?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();' />
<?php  ?>

This may carry you a similar shortlink that you simply see while you click on the Get Shortlink Button under your put up title.

Get Shortlinks in WordPress Theme

By default it’s or one thing related. However that may be changed with different providers through the use of any shortlink plugin that makes use of the “get_shortlink” filter to override the shortlink correctly like Stats for ( or WP Bitly for ( or PRO)

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

Code Preview in WordPress Theme

Supply: OttoPress

Comments (0)

Leave a Reply

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