Skip Navigation

[Resolved] Removing the word “Archives” from Content Type archive page title

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 4 replies, has 4 voices.

Last updated by liatG 1 month, 1 week ago.

Assigned support staff: Minesh.

Author
Posts
#1736499

I have a CPT “Glossary.” The archive page is hidden link. I have tried to remove the word “Archives” from the page title several ways, including editing the custom layout and adding custom code to my theme as per ticket https://toolset.com/forums/topic/split-remove-the-word-archive-from-archive-page-titles/. I haven’t been successful. Can you help?
Here is a Loom video detailing the issue. Thanks!
hidden link

#1737307

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Would you allow me temporary access to your site backend to check this issue closely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1738399

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Jamal is on Vacation. This is Minesh here and I'll take care of this ticket. Hope this is OK.

I've added the following code to "remove-archive-title" code snippet you added to "Custom Code" section offered by Toolset:
=> hidden link

add_filter( 'get_the_archive_title','func_remove_archive_word_title',20,3); 
function func_remove_archive_word_title($title) {
  
  if(is_post_type_archive('glossary')){  
    $temp = explode(':',$title);
    if(count($temp) > 1){
      return $temp[1];
    }
   }
}

I can see now "Archives:" word is removed from the archive page: hidden link

#1738527

Another way to do this is;

add_filter( 'get_the_archive_title', 'paulg_5_get_the_archive_title' );

function paulg_5_get_the_archive_title( $title ) {
    $prefixes_to_remove = array(
        'Year: ',
        'Archives: ',
        'Company: ',
        'Category: '
        // Add other prefixes you want to remove...
    );
 
    foreach( $prefixes_to_remove as $prefix ) {
        // If title starts with $prefix, remove it and finish
        if( $prefix == substr( $title, 0, strlen( $prefix ) ) )  {
            return substr( $title, strlen( $prefix ) );
        }
    }
 
    // No prefix was matched
    return $title;
}
#1739987

Thank you, I tried the code you gave me but it actually removed the entire page title from all archives except Glossary. I searched again and found an Astra Pro forum post with the fix:

add_filter( 'get_the_archive_title', 'wpsite_archive_title_remove_prefix' );
function wpsite_archive_title_remove_prefix( $title ) {
if ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
}
return $title;
}

This worked correctly. Thank you for your help and sorry for the trouble!