WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to overwrite a <head><title>Category title</title></head> tag?

Let's say i have a "Videos" category, when user point's his browser to www.website.com/category/videos/, the page title (this one in head section) is Videos. What i need to do is to somehow overwrite it to display Archive string (without changing this category title), it can be hardcoded in some way cause i have just this one single category.

Any help would be appreciated.

share|improve this question
up vote 2 down vote accepted

You can use the wp_title filter to modify the output of the wp_title function.

quick example based on the example from Codex:

add_filter( 'wp_title', 'wpa66574_title_filter', 10, 3 );

function wpa66574_title_filter( $title, $sep, $seplocation ) {
    // account for $seplocation
    $left_sep = ( $seplocation != 'right' ? ' ' . $sep . ' ' : '' );
    $right_sep = ( $seplocation != 'right' ? '' : ' ' . $sep . ' ' );

    $page_type = '';

    // get special page type (if any)
    if( is_category( 'videos' ) ) $page_type = $left_sep . 'Archive' . $right_sep;

    // get the page number
    if( get_query_var( 'paged' ) ) $page_num = $left_sep. get_query_var( 'paged' ) . $right_sep; // on index
    elseif( get_query_var( 'page' ) ) $page_num = $left_sep . get_query_var( 'page' ) . $right_sep; // on single
    else $page_num = '';

    // concoct and return title
    return $page_type . $title . $page_num;
share|improve this answer

Depending on your theme, in the header.php template, just find the line with the <title> tag, something like this:

<title><?php wp_title( '' ); ?></title>

Then check which page type you're on and edit as necessary:

    <?php if ( is_category( 'video' ) ) echo 'Archive: '; ?>
    <?php wp_title( '' ); ?>

Keep in mind that themes and plugins mess with the <title> tag all the time, so you might run into conflicts. If you don't want to mess with your theme directly, try a plugin that can handle this, like WordPress SEO.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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