title: Redirecting to 404 page from WordPress plugin
body: <p>I am trying to redirect the user to the theme 404.php template from a custom plugin if certain products are not found. Any ideas on this?</p>
  
  <pre><code>protected function get_id() {
      $product_id = $_GET['product_id'];
  
      $product = get_post( $product_id );
  
      if ( empty( $product ) ) {
          // Time to 404.
          $error_page = get_404_template();
          header("HTTP/1.0 404 Not Found");
  
          include($error_page);
  
         // neither works
  
          get_template_part('404');
  
          die();
      }
      else {
          $this-&gt;product_id = $product_id;
      }
  
  
  }
  </code></pre>