Is there a hook filter to get a custom field for the taxonomy name instead of the default field?

For example, a multi-language site.

I have 2 ACF fields for Taxonomy Title. One for the Chinese site and the other for the English site. So when the visitor changes the language of the site. The name of the collection, each element corresponding to the name of the word breadcrumb, can be changed dynamically.

I tried the filter below, but I’m not sure if this is the filter I should be looking for.

add_filter( 'term_name', function( $value ) {
    $current_language = get_locale();
    $field_zh = get_field('zh_title');
    $field_en = get_field('en_title');

    if ( $current_language == 'zh_HK' ){
        return $value[$field_zh];
    elseif ( $current_language == 'en_HK' ) {
        return $value[$field_en];
    return $value;
} );

Leave a Comment