Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Description

On normal page State the Permalink is the Page Permalink:

get_header();
$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:

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

1 Answer 1

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

 
discard

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.