Skip Navigation

[Resolved] Remove taxonomy name from page titles

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer asked how to remove the taxonomy name from the taxonomy archive title

Solution:
Suggested using the 'get_the_archive_title' filter and shared an example code snippet.

Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_the_archive_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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by michaelH-44 1 year, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2403867

Hello,

The singular name taxonomy for my business directory listings is called "Directory Category". This text is displayed before the individual categories on each listings page. How can I remove the "Directory Category:" portion from the page title?

An example would be: Directory Category: Accommodations.

Cheers,

#2404015

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

This additional label text in the titles of the archive pages is added by WordPress, by default.

To remove it, "get_the_archive_title" filter can be used:
https://developer.wordpress.org/reference/functions/get_the_archive_title/

For example:


function custom_archive_archive_title($title) {
    if ( is_tax() || is_category() ) {
        $title = single_cat_title( '', false );
    } elseif ( is_tag() ) {
        $title = single_tag_title( '', false );
    } elseif ( is_author() ) {
        $title = '<span class="vcard">' . get_the_author() . '</span>' ;
    }
    return $title;
}
add_filter( 'get_the_archive_title', 'custom_archive_archive_title');

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

As a result, the extra text label will be removed from the titles of category, tag, all custom taxonomies, and author archives.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2404261

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.