Is it possible to change the page title with code?
For example, let’s say the page’s name is “Book your Order”, but I want to change it to “Book Order #123”.
I Google’d a bit and looked here and didn’t see anything. Anyone know of a plugin or hack?
wp_title returns the page title but doesn’t allow setting the page title:
http://codex.wordpress.org/Function_Reference/wp_title
There is no documentation on it but you could always apply a filter to the_title
like this:
add_filter('the_title','some_callback');
function some_callback($data){
global $post;
// where $data would be string(#) "current title"
// Example:
// (you would want to change $post->ID to however you are getting the book order #,
// but you can see how it works this way with global $post;)
return 'Book Order #' . $post->ID;
}
See these:
http://codex.wordpress.org/Function_Reference/the_title
http://codex.wordpress.org/Function_Reference/add_filter