WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

I have a big issue on catching attributes from global $post_object in a page template file.

I have a Template Name: Blog Page which is template-blog.php

On that page I use the current page permalink to load more posts using Ajax.

So basically I do Ajax Requests in the same URL, and on template-blog.php is a condition if $_POST['load_more'] is true, if yes than return a portion of posts.

My problem is I cant get the page ID or page permalink using the $post variable when this page is set as the Blog Page on WordPress (Settings-Reading-Posts Page).

When the template-blog.php is set-up as the posts page, the $post variable is the first post which $wp_query has on it's post's array.

I hope I was clear enough.


On normal page State the Permalink is the Page Permalink:

$link = get_the_permalink();

But when this page is set-up as Posts Page the Permalink is the Permalink of the first posts on $wp_query:

$link = get_the_permalink();
share|improve this question

Do not post the AJAX request to the page you are viewing, use the AJAX API instead.

To get the permalink for the blog page use:

get_permalink( get_option( 'page_for_posts' ) );
share|improve this answer
Ok than forget about Ajax, but how can i get the Permalink if i need if page is on that State ? – Burimi Jan 4 '13 at 10:50

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.