Incorrect category page titles

A few of our themes have code that automatically displays the category title on  category pages. A small number of sites (less than 1%) that use these themes have experienced "mismatched" category titles. For example, you click on a category called "Travel" but the category title says something different, like "Fashion." This mismatching has something to do with how category titles are configured in the backend on certain sites.

Since such a small amount of sites encounter this, we've decided to keep the automatic category titles code in place for the time being. Below is the fix for this issue.

How to fix mismatched category titles

1. Go to Wordpress > Appearance > Editor.

2. Press Ctrl+F (or Command+F on Mac) and search the word "automatic."

3. You'll be taken to this code snippet shown below. This is from the Amelia theme, so if you're using a different theme, it'll look slightly different.

//* Automatic titles on archive pages
function amelia_default_term_title( $value, $term_id, $meta_key, $single ) {
    if( ( is_category() || is_tag() || is_tax() ) && 'headline' == $meta_key && ! is_admin() ) {
    
        // Grab the current value, be sure to remove and re-add the hook
        remove_action( 'get_term_metadata', 'amelia_default_term_title', 10 );
        $value = get_term_meta( $term_id, 'headline', true );
        add_action( 'get_term_metadata', 'amelia_default_term_title', 10, 4 );
        // Use term name if empty
        if( empty( $value ) ) {
            $term = get_term_by( 'term_taxonomy_id', $term_id );
            $value = $term->name;
        }
    
    }
    return $value;      
}
add_filter( 'get_term_metadata', 'amelia_default_term_title', 10, 4 );

4. Remove this code snippet in its entirety. Be very careful to remove ONLY what's shown above – nothing more, nothing less. Click Update File.

5. If you want to add back your category titles, it can be done manually. Go to Wordpress > Posts > Categories. Click Edit on a category. Add your title in the "Archive Headline" box. Repeat for any other categories you wish to add titles too.