Create Shortcode for the Permalink in WordPress

You can create a shortcode for the permalink in WordPress to use in a string output or more likely as a value for a link attribute, this can be handy if you can’t use PHP in a certain interface.

add_shortcode( 'my_permalink', 'my_permalink' );
// The Permalink Shortcode
function my_permalink() {
ob_start();
    the_permalink();
return ob_get_clean();
}

So you would add this snippet in your themes function.php file and to you the shortcode you would use

[my_permalink]

Or as a link attribute…

<a href=”[my_permalink]” >CLICK ME</a>