title: How to disable 404 header on specific Wordpress url
body: <p>I use this code to redirect specific url to a php file on my custom made Wordpress theme:</p>
  
  <pre><code>add_action('wp', function() {
  if ( trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/') === 'pagename' ) {
  include(locate_template('mysciprt.php'));
  exit();
  }});
  </code></pre>
  
  <p>(I know i can use rewrite rules but i need to use this code for a few reasons).</p>
  
  <p>It's work's great. the problem is the page still has a http header with 404 status. and that's a problem for a few reasons (some of them are: seo, post scripts cant be used...).</p>
  
  <p><strong>My question is:</strong> Is there any way to fix it?</p>
  
  <p><strong>What i have tried:</strong></p>
  
  <p>I tried adding:</p>
  
  <pre><code>global $wp_query;
  status_header(200);
  $wp_query-&gt;is_page = true;
  $wp_query-&gt;is_404  = false;
  </code></pre>
  
  <p>Didn't help at the beginning, then i changed my <code>action('wp'..</code> to <code>action('init'...</code> and it works! but the problem is the reason i am using the <code>'wp'</code> and not <code>'init'</code> is because i need to use <code>get_query_var()</code> on this script and i can't when using the <code>'init'</code> action.</p>