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>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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%%
Method 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_partsandwp_title, and in either instance you have the opportunity to manipulate the results of the standardwp_title(). - Look at functions.php within the theme; the function
twentytwelve_wp_titleperforms some magic specific to twentytwelve, and is activated using thewp_titlefilter 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:
- Allow WP and twentytwelve to do their thing.
- Come along after the fact, and just before
wp_title()returns its string we have an opportunity to manipulate it using thewp_titlefilter.- 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.
Method 3
Go this link (change www.yourwebsite.com with your domain )
www.yourwebsite.com/wp-admin/admin.php?page=wpseo_titles
then click on the tab : Taxonomies
The first tab is your target
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0