Site logo

[Support request] How to remove taxonomy prefix from generate_archive_title

Home Forums Support [Support request] How to remove taxonomy prefix from generate_archive_title

Home Forums Support How to remove taxonomy prefix from generate_archive_title

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2506288
    Wesley

    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?

    #2506330
    Ying
    Staff
    Customer Support

    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;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.