Shortlink trick

Add this code snippet to your single.php or within the loop of your theme. This will display a text field and when clicked becomes selected for easy copy and paste.

 

 

<?php if (function_exists('wp_get_shortlink')) { ?>
<div><span class="post-shortlink">Shortlink:
<input type='text' value='<?php echo wp_get_shortlink(get_the_ID()); ?>' onclick='this.focus(); this.select();' />
</span></div>
<?php } ?>

Leave a comment