How To Get Permalink Outside The Loop In WordPress Blog

Posted by


Many wordpress users having a question in their mind that how can I access the post outside the loop area. Now, it is possible to do it with simple hack. To get a permalink outside of the loop you have to use the get_permalink() function.

That function takes a single argument which is the ID of the post you would like to get the permalink:

<a href=”<?php echo get_permalink(10); ?>” >Read the article</a>

You can also use this function with the $post global variable:

<a href=”<?php echo get_permalink($post->ID); ?>” >Read the article</a>


Shane G.

Leave a Reply

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