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!!
}
Related Posts:
- All top-level pages are using index.php as template
- Changing permalink name redirects to another template?
- Permalink / sub-template issue
- the_title() and the_permalink() won’t work on AJAX calls
- Is it possible to list post attachments in a sub URL endpoint with a dedicated template?
- What is a good way to present templated content in WordPress?
- Adjust which tempalte a page uses with a function?
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- Link to blog index from template
- Is there a wordpress function that I can use to retrieve the current page that is loaded?
- Change author slug and functionality
- Avoid WordPress categorizing a permalink request as Not found 404 Page
- Get the url of a page template without using the page slug and ID
- WordPress Not Using Template Files After Permalink Update
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- Environment independent way to link to certain pages on frontend
- Permalink for specific page name
- implement separate templates for 1 post type
- How to Custom Edit Post Title & Permalink Slug?
- post permalinks with dot in url don’t resolve to correct page template
- Access or edit custom generated permalinks with WP_Rewrite
- Get Posts Based on Tag Matching Page Title
- optional parameter in permalink structure
- Custom permalink structure for remote content pages
- Ajax Call in page theme not working?
- How to make different urls for some tags pages
- Permalinks causing wp-json to 405
- Multiple URL rewrite rules and get every prams
- Single.php not loading when permalink only contains date information
- Rewrite single template permalink?
- “post-name” Renders Using page.php, but “post-name-2” renders with single.php
- single.php being ignored, going straight to attachment.php
- How can I get WordPress CPT archives and page templates to work with prettified permalink settings?
- Pages included in another page and duplicate content issues for SEO
- Select page/template from the permalink url
- Include other parameters in permalinks for better management of browser history
- Text in permalink
- wp_get_attachment_url not working
- Leverage permalinks with AJAX
- Choose template depending on URL
- Getting the terms from “Beautiful Taxonomy Filters” Results ot Integrate into “Ajax Load More”
- Image not Showing (Can see image in inspect element)
- Passing and retrieving query vars in wordpress
- Get the current page URL (including pagination)
- Setting up WordPress with Custom Permalinks and no .htaccess File?
- mod_rewrite enabled but Permalinks show index.php
- Why does /wp-json/ not work on the “plain” permalink structure?
- Custom Permalink: /year/month/post-goes-here/?
- Turn off %postname% auto-incrementing?
- How to get the post id from a permalink?
- Does a parent page’s post_title have to appear in a child page permalink?
- Stop redirecting to posts not in a category / duplicate slugs
- Hide Front-End Admin Bar Including 32 px Spacing
- How to make variables in URL look like the permalink structure?
- Custom Taxonomy URL
- Custom Post Type slug same as page name causing a conflict
- How to improve WordPress security by hiding non public facing files?
- CSS not loaded when omitting www. part of URL
- Is it possible to keep all special letters for foreign languages in slug as in title?
- How to load all pages into one page with their templates
- index.php is always displayed before any file on the URL
- how could I load a different template part by page
- How do I fix permalink and media library issues on a LEMP stack?
- Non latin post slug truncate
- Page preview is shown, updating page gives 404 error
- Dynamic Template file for subpage
- How to 301 redirect from one url to another properly
- Advanced author permalinks
- Format HTTP links
- Permalinks on post is working, on pages 404 error
- Change directory url to be same as page permalink?
- Permalinks set to /%postname%/ but still have links being indexed in the form ?p=x
- WordPress author.php template does not work with custom permalink structure! Help!
- LAMP WordPress Permalinks 404 error
- Links in post content don’t work on home page
- Arabic permalink redirect to home page
- Changing permalink settings causes 404
- One Custom Post Type two different Templates
- Custom permalink structure for product
- index.php in URL
- archive by year and category: permalink support doesn’t work on pagination
- Empty the_excerpt() broke the_permalink() under him?
- Permalink not changing according to post type
- iFrame permalinks on WordPress
- Custom permalink structure with a prefix just for posts
- WordPress Pages that use Domain URL
- 404 page not found – Yet open admin page it works
- How can I have a page’s permalink include my custom post type’s slug?
- WordPress Permalinks
- Problem with permalinks
- Find internal links to post
- “Undefined” added to page content after google Adwords click
- Image upload ruined my links
- How to rewrite a folder in WordPress?
- Tag search not working after permalink structure change
- Custom permalink to make a page respond properly
- WordPress 3.1 problem, getting 404
- Display a custom slug in URL depending on user variable
- What happens to bespoke page template references on theme change?
- Permalinks get lost periodically