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'm looking to get the page content between the header and footer (as Wordpress already does) that includes the template HTML (as this is going to be an AJAX request).

Is there a function that will allow me to do this? The only things I have found so far all relate to just getting the content straight from the database.

It would also be great to get this content via the pages' permalink.

share|improve this question
    
To what ends? You want it as a PHP variable? What are you trying to do with it? A little more context would be helpful –  Tom J Nowell Sep 21 '12 at 14:35

1 Answer 1

up vote 0 down vote accepted

Here's how to check if the current page is being loaded via an AJAX request, use this to exit from the header/footer/whichever parts

/* AJAX check  */
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
  return; // it's an ajax request ABORT!!
}
share|improve this answer

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.