Site logo

Archived topic

How to remove taxonomy prefix from generate_archive_title

1 reply · Started by Wesley on January 23, 2023

Viewing posts 1–2 of 2

I currently have a custom taxonomy called "Services" on my site.

On the frontend, the individual term archive automatically prefixes the title with "Service" (for example, "Service: Web Design").

I don't want to prefix the title with the taxonomy name on this template, and I couldn't find an option to turn it off in the Customizer.

The title is being called by generate_archive_title in the template — would you be able to provide a snippet to override the filter that is adding the taxonomy name at the beginning?

Hi Wesley,

Try this:

add_filter( 'get_the_archive_title', 'yh_filter_the_archive_title' );
function yh_filter_the_archive_title ($title) {
	if (is_tax( 'service' ) ) {
		$title = single_term_title( '', false );
	}
	return $title;
}
This archived topic is closed to new replies.