How to get full content including template HTML

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.

1 Answer
1

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!!
}

Leave a Comment