Is there a filter hook that I can use to change how taxonomy term names are displayed?

I need to hide a custom taxonomy‘s terms‘ names on the frontend while preserving them on the backend. Instead of the terms’ names I need to display pseudonyms. I can’t find a single filter hook to do that. I’ve tried the ones in sanitize_term_field but that only works when the context is ‘display’. It seems most of the time the context is ‘raw’ and there is no hook for that. Does anyone know how to filter term names before they are displayed on the frontend?

Solutions Collecting From Web of "Is there a filter hook that I can use to change how taxonomy term names are displayed?"

The dynamic filter "term_{$field}" is probably what you’re looking for, where the field is “name.”

One approach is to have an array of names and their pseudonyms, then do a check-and-return on them so they’ll display the replacement.

add_filter( 'term_name', function( $value ) {
    $terms = [
      'old' => 'new',
    ];

    // basic example check, loop through an array for real
    if ( 'old' === $value ) {
        return $terms['old'];
    }

    return $value;
} );