If you’re building out custom functionality or a plugin in WordPress, chances are you’re eventually going to need to get a permanent link to a post while outside of the loop.

Here’s how…

function my_function() {
  global $post;
  get_permalink($post->ID);
}

Easy.

Category:
Notes
Tags:

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.