Zahid Iqbal Zahid Iqbal - 25 days ago 4
PHP Question

Removing some text in main title on product category archives pages

On my WooCommerce web shop, I would like to remove

Archive of :
from main title on product category archives pages.

Here is a screenshot:

I have tried to use this code based on this answer,
But it doesn’t work:

function changing_category_archive_page_title( $page_title ) {
if(is_product_category()) {
$title_arr = explode(' :', $page_title);
$new_title = $title_arr[2];
if(!empty($new_title)) echo $new_title;
else echo $page_title;
add_filter( 'woocommerce_page_title', 'changing_category_archive_page_title', 10, 1 );

How can I do to remove
Archive of :
from title?



It seem that this 'Archive of : ' text is a customization of your theme, as it doesn't exist in classic WooCommerce. So in this case, it's normal that the code you are using doesn't work.

Without any guaranty, as I can't test it my self, you should try to use the WordPress gettex() function, as I think that this is an addition to main title, as some themes use to do:

add_filter( 'gettext', 'removing_specific_text_in_categories_page_titles', 10, 2 );
function removing_specific_text_in_categories_page_titles( $translated_text, $untranslated_text )
    if ( 'Archive of :' == $untranslated_text ) {
        $translated_text = '';
    return $translated_text;

This code goes in function.php file of your active child theme (or theme) or also in any plugin file.