I have a script that I’d like to call via AJAX from my WordPress theme, it relies upon some core WordPress functions so I am including WordPress blog header like so:
define( 'WP_USE_THEMES', false );
require( '../../../../wp-blog-header.php' );
Somewhere during the processing of wp-blog-header.php
WordPress sets a 404 header which causes my AJAX request to fail, even though the script I am calling exists and is returning content.
I have since added status_header( 200 );
after that snippet which changes the status header back to 200 and solves the problem, however it feels very much like a hack, so I was just wondering if there is a recommended solution to this problem?