Modify title-tag based on specific post template file
-
I’ve got a custom post type which uses two batches of template file to display content in different ways depending on a (?) variable in the URL being viewed. What I need to do is disable the
add_theme_support( ‘title-tag’ );when a certain template file is being used, so I can insert a custom title for that post.The template file header.php will work as normal and pull the title from the core. But custom-header.php will not have the title in the
wp_head();and I’ll manually insert one into the <head>. Removingwp_head();from the template isn’t an option and not something I really want to do.I can accomplish what I’m after if the custom post type was a page in the function.php with…
if ( !is_page_template('custom-header.php') ) { add_theme_support( 'title-tag' ); }But it’s a post so this doesn’t work on this occasion and I can’t find an alternative with
wp_title()being deprecated in the near future.The websiteurl.com/post shows the happy WordPress
<title>Post Name</title>. And what I want is websiteurl.com/post?custom which uses the custom-header.php template file already to show<title>Manually Inserted</title>and not<title>Post Name</title>.
The topic ‘Modify title-tag based on specific post template file’ is closed to new replies.