admin管理员组

文章数量:1293565

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>

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>
Share Improve this question edited Sep 30, 2014 at 19:47 sidlo asked Sep 30, 2014 at 11:04 sidlosidlo 1531 silver badge4 bronze badges 2
  • 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 Commented Sep 30, 2014 at 19:25
  • I've edited the question. At category page I get this and I want to get rid of "Archives". – sidlo Commented Sep 30, 2014 at 19:49
Add a comment  | 

3 Answers 3

Reset to default 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%%

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.

Go this link (change www.yourwebsite with your domain )

www.yourwebsite/wp-admin/admin.php?page=wpseo_titles

then click on the tab : Taxonomies

The first tab is your target

本文标签: theme twenty twelveRemove Archives in category title