Not an exact answer for original post’s code setup, but since I came here to answer the same question according to the title I’ll provide my not so elegant solution using ACF (though the same can surely be done with a regular custom field):
TO DISPLAY A SINGULAR VERSION OF YOUR CATEGORY NAME (Example using product cat for woo):
-
Setup a custom field for the category archive
-
Name it singular
-
Implement the custom field in your template by using the following (untested, but code generated using ACF Theme Code plugin):
// Define taxonomy prefix eg category // Use term for all taxonomies $taxonomy_prefix = 'product_cat'; // Define term ID // Replace NULL with ID of term to be queried eg '123' $term_id = NULL; // Example: Get the term ID in a term archive template // $term_id = get_queried_object_id(); // Define prefixed term ID $term_id_prefixed = $taxonomy_prefix .'_'. $term_id; ?> <?php the_field( 'singular_name', $term_id_prefixed ); ?>```