When I need to add a custom page to a WordPress-based site, I always load the theme's header first:
<?php
require('../wp-blog-header.php');
include('../wp-content/themes/mytheme/header.php');
?>
Unfortunately, then every custom page gets the same title (the blog's name) due to this code in header.php:
<head>
<title><?php if(is_home()) { bloginfo('name');} else { bloginfo('name'); echo ' | '; the_title(); } ?></title>
What would be the best way to change this page title?
- Is there a WordPress method to call before loading the header that will change
the_title()
's return value? - Should I change the header.php call, so it will check if there is a previously defined custom value for my title?