In my category pages, the title of the category is shown as the title of the page. I want to have a different title, for SEO purposes. How can this be done?

Say my category is mystery books I want the search engine to see a title like "The Best Mystery Books" instead of "mystery books" that it sees now. I don't care if this title is also shown on the actual page or not.

This is the code I use for the title of category pages:

<header class="page-header">
                    <h1 itemprop="headline" class="page-title">
                        <?php if ( is_category() ) {
                        single_cat_title( '', true );
                        } ?>
                    </h1><!-- .page-title -->
</header><!-- .page-header -->

The "problem" seems to be that WP automatically generates <title> tags from the <header> <h1> of the page. Any ideas?

Maybe I need a function that checks if it is a category and puts the relevant <title> in the <head> of the page?

1 Answer 1


You'll need to change this in, most likely, your header.php file in your themes root. I would suggest that you use something like YoastSEO Plugin which will give you granular manipulation of your sites <title> and <meta> tags. If this is not an option, you would have to dive into the header.php template and update it there.

For example:

<?php if( is_category( 'my-category-slug' ) ) : ?>
    <title><?php _e( 'The Best Mystery Books' ) ; ?></title>
<?php else : ?>
    <title><?php wp_title( '|', true, 'right' ); ?></title>
<?php endif; ?>

Make sure to check that the slug ('my-category-slug') matches your mystery book slug. You can see more about the arguments that can be passed to is_category() for more relevant matching.

  • Thanks. I believe it would work the same without the else.
    – IXN
    Apr 2, 2018 at 19:59
  • if your not on is_category( 'my-category-slug' ) it would output nothing without the else, unless your using a plugin that does this. Apr 3, 2018 at 15:57
  • 'wp_title()' does this automatically already before I added the code, right? I don't see the point to add it.
    – IXN
    Apr 3, 2018 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.