I have already registered a custom taxonomy inside my theme function php file.
Code
$args = array (
'label' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'labels' => array(
'menu_name' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'all_items' => esc_html__( 'All Ποικιλίες', 'text-domain' ),
'edit_item' => esc_html__( 'Edit Ποικιλία', 'text-domain' ),
'view_item' => esc_html__( 'View Ποικιλία', 'text-domain' ),
'update_item' => esc_html__( 'Update Ποικιλία', 'text-domain' ),
'add_new_item' => esc_html__( 'Add new Ποικιλία', 'text-domain' ),
'new_item_name' => esc_html__( 'New Ποικιλία', 'text-domain' ),
'parent_item' => esc_html__( 'Parent Ποικιλία', 'text-domain' ),
'parent_item_colon' => esc_html__( 'Parent Ποικιλία:', 'text-domain' ),
'search_items' => esc_html__( 'Search Ποικιλίες', 'text-domain' ),
'popular_items' => esc_html__( 'Popular Ποικιλίες', 'text-domain' ),
'separate_items_with_commas' => esc_html__( 'Separate Ποικιλίες with commas', 'text-domain' ),
'add_or_remove_items' => esc_html__( 'Add or remove Ποικιλίες', 'text-domain' ),
'choose_from_most_used' => esc_html__( 'Choose most used Ποικιλίες', 'text-domain' ),
'not_found' => esc_html__( 'No Ποικιλίες found', 'text-domain' ),
'name' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'singular_name' => esc_html__( 'Ποικιλία', 'text-domain' ),
),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'show_admin_column' => false,
'show_in_rest' => true,
'hierarchical' => false,
'query_var' => true,
'sort' => false,
'rewrite_no_front' => false,
'rewrite_hierarchical' => false,
'rewrite' => true,
);
register_taxonomy( 'variety-of-drink-spirits', array( 'product' ), $args );
Now I add on directory folder [mytheme/woocommerce/templates/singe-product/meta php] file the below code.
Code
echo get_the_term_list( $product->get_id(), 'variety-of-drink-spirits', 'Ποικιλία: ', ', ', '');
I changed the up-stair code lines with the below.
Code
<?php echo get_the_term_list( $product->get_id(), 'variety-of-drink-spirits', '<span class="posted_in">' . _n( 'Ποικιλία:', 'Ποικιλίες:', count( $term_ids ), 'woocommerce' ) . ' ', ', ', '</span>' ); ?>
- My question is: How I can appearing singular or plural name of my taxonomy depend of result data.
Thank you, Thomas
I have already registered a custom taxonomy inside my theme function php file.
Code
$args = array (
'label' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'labels' => array(
'menu_name' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'all_items' => esc_html__( 'All Ποικιλίες', 'text-domain' ),
'edit_item' => esc_html__( 'Edit Ποικιλία', 'text-domain' ),
'view_item' => esc_html__( 'View Ποικιλία', 'text-domain' ),
'update_item' => esc_html__( 'Update Ποικιλία', 'text-domain' ),
'add_new_item' => esc_html__( 'Add new Ποικιλία', 'text-domain' ),
'new_item_name' => esc_html__( 'New Ποικιλία', 'text-domain' ),
'parent_item' => esc_html__( 'Parent Ποικιλία', 'text-domain' ),
'parent_item_colon' => esc_html__( 'Parent Ποικιλία:', 'text-domain' ),
'search_items' => esc_html__( 'Search Ποικιλίες', 'text-domain' ),
'popular_items' => esc_html__( 'Popular Ποικιλίες', 'text-domain' ),
'separate_items_with_commas' => esc_html__( 'Separate Ποικιλίες with commas', 'text-domain' ),
'add_or_remove_items' => esc_html__( 'Add or remove Ποικιλίες', 'text-domain' ),
'choose_from_most_used' => esc_html__( 'Choose most used Ποικιλίες', 'text-domain' ),
'not_found' => esc_html__( 'No Ποικιλίες found', 'text-domain' ),
'name' => esc_html__( 'Ποικιλίες', 'text-domain' ),
'singular_name' => esc_html__( 'Ποικιλία', 'text-domain' ),
),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'show_admin_column' => false,
'show_in_rest' => true,
'hierarchical' => false,
'query_var' => true,
'sort' => false,
'rewrite_no_front' => false,
'rewrite_hierarchical' => false,
'rewrite' => true,
);
register_taxonomy( 'variety-of-drink-spirits', array( 'product' ), $args );
Now I add on directory folder [mytheme/woocommerce/templates/singe-product/meta php] file the below code.
Code
echo get_the_term_list( $product->get_id(), 'variety-of-drink-spirits', 'Ποικιλία: ', ', ', '');
I changed the up-stair code lines with the below.
Code
<?php echo get_the_term_list( $product->get_id(), 'variety-of-drink-spirits', '<span class="posted_in">' . _n( 'Ποικιλία:', 'Ποικιλίες:', count( $term_ids ), 'woocommerce' ) . ' ', ', ', '</span>' ); ?>
- My question is: How I can appearing singular or plural name of my taxonomy depend of result data.
Thank you, Thomas
Share Improve this question edited Feb 6, 2020 at 17:08 asked Feb 6, 2020 at 12:00 user182138user1821381 Answer
Reset to default 0The final solution of plural and singular terms name is below.
Code
<?php $term_ids = wp_get_post_terms( $product->get_id(), 'variety', array('fields' => 'ids') );
echo get_the_term_list( $product->get_id(), 'variety', '<span class="posted_in">' . _n( 'Ποικιλία:', 'Ποικιλίες:', count( $term_ids ), 'text-domain' ) . ' ', ', ', '</span>' ); ?>
In my project is working correct :) Hope to help anyone to fix this issue !
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744767711a4592561.html
评论列表(0条)