Search code examples
wordpresscustom-post-type

Change page title of custom archive page that is set to the homepage


First, I've reviewed a few questions (including this one, and also tried plugins but I can't get the below working.

I'm using an archive as my homepage;

  • The archive is a custom post type of film_kernal.
  • The label is Kernals.
  • The homepage title is currently Kernals Archive - [Site Title]
  • The individual custom taxonomy archive pages have a title of [Taxonomy Term] - [Site Title]

The taxonomy pages have the correct title however I want the homepage to just read Home - [Site Title]. How can this be done without changing the currently correct titles of the taxonomy term pages?

I'm using the TwentySeventeen theme, and the default header file seems to use wp_head to retrieve the title but I'm not confident on how to affect this in a child header file to get things working.


Solution

  • Since you use Yoast you can override the the title tag with this filter

    add_filter('wpseo_title', 'filter_film_kernal_wpseo_title');
    function filter_film_kernal_wpseo_title($title) {
        if(  YOUR_CASE_HERE ) {
            $title = //your code
        }
        return $title;
    }