WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose that I create a page in the admin section (under 'Pages') and I have permalinks turned on and this pages slug is 'my-new-page', then is there a WordPress function that will work outside the (blog) Loop that I can use in that page's template on my theme that will retrieve that page's permalink?

share|improve this question
get_permalink() ? – onetrickpony Jan 14 '11 at 0:14
Thanks for your help guys. – racl101 Jan 16 '11 at 2:21
up vote 4 down vote accepted

Hi @racl101:

I think what you are after is to use get_page_link($post->ID). The value $post will have been set by the default query to be equal to the post for the current page and should be in scope when your page template is run.

share|improve this answer
Also if your code is in a function, make sure that you make $post global. – Manny Fleurmond Jan 14 '11 at 3:08
@Manny Fleurmond - Good point. – MikeSchinkel Jan 14 '11 at 5:59
Wow thanks Mike! That totally worked. – racl101 Jan 20 '11 at 0:49
@racl101 - You are welcome. :) – MikeSchinkel Jan 20 '11 at 6:49

yes first of all you would need to require wp-load.php in your custom area using this code:

 require( '../my_wordpress_install_root/wp-load.php' ); ?>

And after that you can follow thsi tut to call any page : http://www.snilesh.com/resources/wordpress/wordpress-tips-and-tricks/wordpress-get-page-content-by-page-id/

share|improve this answer
The original question describes then need to call it outside the Loop, but still in WordPress templates - core would be loaded just fine as usual. – Rarst Jan 14 '11 at 6:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.