WordPress external pages false 404 headers fix and page title fix

When creating external pages but require wordpress hooks and theme functions, the WordPress theme development site tells us to do the following in the header of the external page.

define(‘WP_USE_THEMES’, false);



However as many people have experience it half-works, WordPress then spits out a 404 header but STILL displays the content of the external page (barring IE which might display a 404 error message). To combat this the simple fix is to add the following .

define(‘WP_USE_THEMES’, false);


header(“HTTP/1.1 200 OK”);

header(“Status: 200 All rosy”);

So now the browser sees the page with the correct Code 200 header, fine, except wordpress STILL displays the title of the page as “Page not found”, the fix for this is simply setting a global var and adding a conditional statement to the original <title>….<title> section in your theme’s header.


<title><?php wp_title(”); ?><?php if(wp_title(”, false)) { echo ‘  | ‘; } ?> <?php bloginfo(‘name’);  ?></title>



<title><? global $title; ?><? if ($title): ?><?=$title?> <?php echo ” | “; bloginfo(‘name’); ?> <? else: ?><?php wp_title(”); ?><?php if(wp_title(”, false)) { echo ‘ &nbsp;|&nbsp;’; } ?> <?php bloginfo(‘name’);  ?><? endif; ?></title>


Additionally at the top of the external page header you need to add the following before your get_header(); call:

global $title;

$title = ‘Page title here’;


You may also like...

2 Responses

  1. fawad imam says:

    Hi It is giving me header already sent error.

Leave a Reply

Your email address will not be published. Required fields are marked *