views:

46

answers:

1

Hi,

I'm running a site powered by WordPress with extra pages... To integrate these pages with the WordPress theme I use this code:

<?php
$blog_longd='Title'; // page title
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
get_header();
?>

html code

<?php
get_sidebar();
get_footer();
?>

This works fine, however page title shows always 404 Error Page (not "Title").

It seems that $wp-query->is_404 is always set to true. I tried overriding this value but it doesn't seem to work. I tried fixing it by putting header status 200 above function get_header()..also it doesn't work.

Any suggestions? Thanks

A: 

Maybe clumsy, but if you implement the wp_title filter, you can change the title to what you want. You can add this code to the header of each custom page:

add_filter('wp_title', 'replace_title');
function replace_title() {
   return 'My new title';
}

If you want it a bit cleaner, use a smarter version of this filter to a plugin, and set only the global variable (here $override_title) in your page:

add_filter('wp_title', 'replace_title_if_global');
function replace_title_if_global($title) {
   global $override_title;
   if ($override_title) {
      return $override_title;
   }
   return $title;
}
Jan Fabry