• Resolved Tim Derouin

    (@tderouindesign)


    We are setting up a store using WooCommerce for a book publisher and are using “Tags” for the author names.

    I have found documentation on how to customize the product tags label to what I would like in the backend. However, how can I change “Tags: Jane Doe” on the front end of the website so it reads “Author: Jane Doe”?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ryan Ray, a11n

    (@ryanr14)

    Hi @tderouindesign,

    I found a snippet for this here, if you just modify it to work for authors instead of brands.

    
    add_filter('gettext', 'author_translate_tag_taxonomy');
    add_filter('ngettext', 'author_translate_tag_taxonomy');
     
    function author_translate_tag_taxonomy($translated) {
     
    if ( is_product() ) {
    // This will only trigger on the single product page
    $translated = str_ireplace('tag', 'author', $translated);
    }
     
    return $translated;
    }
    

    I’d recommend you use a plugin like Functionality for Pluginception to store this custom code in. That way it’s update safe from anything overwriting it. ??

    Thread Starter Tim Derouin

    (@tderouindesign)

    Thank you for the reply @ryanr14!

    I ended up going with the following code in my functions.php file:

    /* Customize Product Tags Labels */
    add_filter( 'woocommerce_taxonomy_args_product_tag', 'custom_wc_taxonomy_args_product_tag' );
    function custom_wc_taxonomy_args_product_tag( $args ) {
        $args['label'] = __( 'Authors', 'woocommerce' );
        $args['labels'] = array(
            'name'              => __( 'Authors', 'woocommerce' ),
            'singular_name'     => __( 'Authors', 'woocommerce' ),
            'menu_name'         => _x( 'Authors', 'Admin menu name', 'woocommerce' ),
            'search_items'      => __( 'Search Authors', 'woocommerce' ),
            'all_items'         => __( 'All Authors', 'woocommerce' ),
            'parent_item'       => __( 'Parent Author', 'woocommerce' ),
            'parent_item_colon' => __( 'Parent Author:', 'woocommerce' ),
            'edit_item'         => __( 'Edit Author', 'woocommerce' ),
            'update_item'       => __( 'Update Author', 'woocommerce' ),
            'add_new_item'      => __( 'Add New Author', 'woocommerce' ),
            'new_item_name'     => __( 'New Author Name', 'woocommerce' )
        );
        return $args;
    }
    

    I did not want to install another plugin and felt like this approach was better for me. I do not recall where I obtained the code from. Probably WooCommerce support but I am not sure as a lot of searching went in to it! Either way, this can be marked as resolved.

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change “Tag” on frontend of website’ is closed to new replies.