WordPress Product Page Change Label From ‘Category’ to ‘Artist’

On a News site, we changed the post taxonomies Category and Tag to Departments and Topics. This works in all the screens on the back end; if you’re using WordPress’s functions get_terms() or similar, they should also be translated on the front end, I believe.

Something like the code below work to change Category to Artist, assuming you’re using the (Post) Category taxonomy. If not, you might need to figure out the name of the taxonomy and adjust the taxonomy_labels_{$taxonomy} filter to suit.

add_filter( 'taxonomy_labels_category', 'wpse418337_rename_taxonomies' );

/**
 * Renames the taxonomy labels.
 *
 * @param  stdClass $labels The taxonomy label set.
 * @return stdClass         The filtered label set.
 */
function wpse418337_rename_taxonomies( $labels ) {
    // Search for these strings...
    $find = array(
        'Categories',
        'categories',
        'Category',
        'category',
    );
    // ...and replace 'em with these strings.
    $replace = array(
        'Artists',
        'artists',
        'Artist',
        'artist',
    );
    foreach ( $labels as $key => $label ) {
        if ( 'name_admin_bar' !== $key ) {
            $labels->$key = str_replace( $find, $replace, $label );
        }
    }
    return $labels;
}

Note: This code is untested and may need customization for your site. Don’t test it in production. It’s also not i18nized; if you need translations, you’ll need to familiarize yourself with WordPress’s __() and related functions.

References

  • taxonomy_labels_{$taxonomy} — filters the taxonomy labels; the last part, {$taxonomy}, is the name of the taxonomy you’re editing; I’ve used category but you’ll need to make sure you know what taxonomy your installation uses
  • get_taxonomy_labels() — shows the full list of taxonomy labels

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino