I’m having trouble with adding a custom php page to have wp style (header and footer), and i succeeded but the issue is that it appears as a 404 error not a 200 success.
the header is like this:
<?php
include $_SERVER['DOCUMENT_ROOT']."/wp-blog-header.php";
include $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/theme_name/header.php";
?>
and i NEED to have this page like an is_single
or is_page
or something to not be 404 page with that error.
i tried:
global $wp_query;
$wp_query->is_404 = false;
and:
global $wp_query;
$wp_query->is_page = true;
but both didn’t work, please help!
You should use
wp-load.php
, notwp-blog-header.php
. because the usage of wp-blog-header.php si only for wordpress files not out side files.Take a look at this link:
https://gist.github.com/gyrus/3332597.
I think the key is that you have to call
status_header( '200' );
in order to get it to work.Here’s another relevant link: http://sltaylor.co.uk/blog/intercept-wordpress-404s/
I had this problem as well but the following worked well for me in WordPress 4.7