4

How I can remove word "Archives" in head title in category page?
I'm using the Twenty Twelve theme and WordPress 4.

<head>
<title>"name of category" Archives  | "name of sites"</title>
</head>
  • I don't understand your question, and it seems that the user who answered your question also misunderstood you. Please add a snapshot of what you need to remove – Pieter Goosen Sep 30 '14 at 19:25
  • I've edited the question. At category page I get this and I want to get rid of "Archives". – sidlo Sep 30 '14 at 19:49
6

If you are using yoast SEO plugin then the easiest method is to remove the archive word from "titles & metas-> Taxonomies->category"

find:

%%term_title%% Archives %%page%% %%sep%% %%sitename%%

replace it with:

%%term_title%% %%page%% %%sep%% %%sitename%%
  • Sorry, I said that confusedly. I meant the word Archives in <head><title>.. I found what you advised me but nowhere the title of category sites. – sidlo Sep 30 '14 at 18:37
  • Ok...i just edited my answer please check that in your site.. – Zammuuz Oct 1 '14 at 3:06
  • @sidlo: if you resolve the issue using this then please accept it as the answer – Zammuuz Oct 6 '14 at 3:35
2

Some points of interest:

  • The code for wp_title() is located with /wp-includes/general-template.php. This function performs two filters: wp_title_parts and wp_title, and in either instance you have the opportunity to manipulate the results of the standard wp_title().
  • Look at functions.php within the theme; the function twentytwelve_wp_title performs some magic specific to twentytwelve, and is activated using the wp_title filter with priority 10.

If you're not familiar with filters, I strongly recommend you look into it before getting too fancy with this. However, my suggested approach takes the following steps:

  1. Allow WP and twentytwelve to do their thing.
  2. Come along after the fact, and just before wp_title() returns its string we have an opportunity to manipulate it using the wp_title filter.
    • For this to work, we'll need to assume a priority of greater than 10 to ensure that we do our thing after twentytwelve has done its part.

Thus, I suggest the following function, invoked using the wp_title filter with a larger (executed later) priority of 11:

function overwrite_twentytwelve_archives_title($title, $sep)
{
    // Look for the string " Archives" (note the leading space), 
    // and strip it out of $title:
    return preg_replace("/ Archives/", "", $title);
}
add_filter("wp_title", "overwrite_twentytwelve_archives_title", 11, 2);

I took some liberty here in assuming that there would be an extra space in front of "Archives" that had to be stripped out as well (noted in the comments); adjust accordingly if you so desire. Basically, what I've suggested here is to allow Wordpress to go about its usual business, only to have the "Archives" bit stripped out just before it's actually displayed. Please note that I haven't tested this to work correctly, and if it doesn't I would be happy to put it through the ringer on my end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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