I need to modify the outputted <title></title>
tag of a few specific templates, and it has to be done in php so I can dynamically generate content for it. I've been playing around with these two snippets of code to get it to work, but so far the only change I've gotten is a duplicated title tag:
remove_filter('wp_title','genesis_default_title', 10, 3);
add_filter('wp_title', 'process_page_titles', 10, 3);
function process_page_titles($title){
if ( is_page_template( 'landing-page-template.php' ) ) {
return 'Select Your Car';
}
elseif( is_page_template( 'dealer-page-template.php' ) ) {
return 'Select Dealers';
}
elseif( is_page_template( 'thank-you-page-template.php' ) ) {
return 'Thank You';
}
elseif( is_page_template( 'ad-page-template.php' ) ) {
return 'Deals!';
}
}
And this one
remove_action('genesis_title','genesis_do_title');
add_action('genesis_title', 'process_page_titles');
function process_page_titles(){
if ( is_page_template( 'landing-page-template.php' ) ) {
echo '<title>';
wp_title( '|','Select Car','right' );
echo '</title>';
}
elseif( is_page_template( 'dealer-page-template.php' ) ) {
echo '<title>';
wp_title( '|','Select Dealer','right' );
echo '</title>';
}
elseif( is_page_template( 'thank-you-page-template.php' ) ) {
echo '<title>';
wp_title( '|','Thank You','right' );
echo '</title>';
}
elseif( is_page_template( 'ad-page-template.php' ) ) {
echo '<title>';
wp_title( '|','Deals!','right' );
echo '</title>';
}
else{
echo '<title>';
wp_title();
echo '</title>';
}
}
These snippets are going to be placed in a PHP file that will be required by each of these page templates; so no need to worry about affecting other page templates since its not in functions.php.