Site logo

Archived topic

Change Titles on "Tags" pages

2 replies · Started by stephen on March 11, 2021

Viewing posts 1–3 of 3

I know it's possible to change the title tag on category pages but was wonder how I would go about doing the same for "tags" pages. Right now we are using the below code for categories. Is there something similar? Basically we want to do this for SEO purpose. We have tags for celebrities and we would like to control the way their name comes up on the tag pages.

<?php add_filter( 'get_the_archive_title', function( $title ) {
    if ( is_category( 'weird-shocking-news' ) ) {
        $title = 'Weird & Shocking News';
    }

    return $title;
}, 50 );
			?>

Never mind. I figured it out with the below code:

<?php add_filter( 'single_tag_title', function( $title ) {
    if ( is_tag( 'kim-kardashian' ) ) {
        $title = 'Kim Kardashian News';
    }

    return $title;
}, 50 );
			?>

Glad to hear :)

This archived topic is closed to new replies.