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?


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;
} );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.