MrRoman
MrRoman

Reputation: 793

Woocommerce: How to remove "Archive" in title?

I'm trying to remove the word "Archive" from the page title.

How to remove it? By adding a filter?

Example:

My collections Archive | My sitename

Upvotes: 19

Views: 52992

Answers (8)

Vincent Rocher
Vincent Rocher

Reputation: 73

You have this filter for all cases : "get_the_archive_title". But then there are different cases.

For exemple for simple category you can do :

function prefix_category_title( $title ) {
  if(is_category()){
    $title = single_cat_title( '', false );
  }
  return $title;
}
add_filter( 'get_the_archive_title', 'prefix_category_title' );

For custom post type you should do :

function prefix_category_title( $title ) {
  if(is_archive('slug-of-your-custom-post-type')){
    $title = single_cat_title( '', false );
  }
  return $title;
}
add_filter( 'get_the_archive_title', 'prefix_category_title' );

So finally you have many condition like :

  • is_category
  • is_archive
  • is_tag
  • is_author
  • is_year
  • is_tax

https://developer.wordpress.org/reference/functions/get_the_archive_title/

Vincent.

Upvotes: 0

Alexander Behling
Alexander Behling

Reputation: 627

in addition to Ted C:

For this purpose Wordpress has already predifined functions starting with __return_. In this case the function you are looking for is __return_false.

add_filter('woocommerce_show_page_title', '__return_false',10,0); will also work.

The last two params are the order of the function and the number of params passed to it.

It is always a good pratice to set them up but this is only necessary if you want to modify the default order (10) and the number of params passed (1).

Upvotes: 0

Sergio Barbosa
Sergio Barbosa

Reputation: 469

If you are using the Yoast SEO (Versión 8.1.2), the options were move to:

Yoast SEO -> Search Appearance -> Taxonomies.

enter image description here

In there look up by Product categories (product_cat) and open it.

enter image description here

Then remove the Archives string from the head.

Upvotes: 15

sourcebreak
sourcebreak

Reputation: 1

wp-content/plugins/woocommerce/templates/archive-product.php

Edit this file archive-product.php and remove the below 3 lines.

                    <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>

            <?php endif; ?>

This will remove page title on shop page and all other pages.

Upvotes: -4

Stephan Muller
Stephan Muller

Reputation: 138

I know this is an old post but I tried the answers here and it didn't work. I found the solution basing it off renegadesk's answer, but in addition of going to the Taxonomies Tab I also had to change it in the Post Types tab. See below:

Get Wordpress SEO by Yoast if you don't already have it, then click SEO > Titles & Metas > Post Types. Scroll down and look for the heading "Custom Post Type Archives". On the "Products", you can edit the content of this title. Mine now looks like this:

%%pt_plural%% %%page%% %%sep%% %%sitename%%

Upvotes: 7

Ted C
Ted C

Reputation: 161

you can rewrite the filter in functions.php so it fails, causing WooCommerce not the render it.

function override_page_title() {
return false;
}
add_filter('woocommerce_show_page_title', 'override_page_title');

Upvotes: 15

Simon Kelly
Simon Kelly

Reputation: 554

Best to use Wordpress SEO by Yoast.

Within Titles & Metas go to the Taxonomies tab and update the Title template for Product Categories to remove the word Archive. Mine ended up looking like this:

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

Upvotes: 31

Win
Win

Reputation: 36

In woocommerce there seem to be 3 instances of Archives (case sensitive) one in \wp-content\plugins\woocommerce\woocommerce-hooks.php around line 50 and 2 in \wp-content\plugins\woocommerce\woocommerce-template.php around lines 240 ish Perhaps one of those is what you're looking for and you may be able to modify code.

Upvotes: 0

Related Questions