Get list taxonomy term attribute slug and name woocommerce product

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi admin, 20/8/21.

  1. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,884
    Đã được thích:
    1,194
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Get list taxonomy term slug and name attribute by url slug woocommerce product trong code PHP như thế nào? lấy danh sách các taxonomy term của attribute bằng url slug của attribute được truyền vào như thế nào?

    get-list-taxonomy term attribute-slug-name.jpg

    PHP:
    $attributeinfo $product->get_attribute'xuat-xu' );
    if(
    $attributeinfo!="")
    {
      
    // Get the array of the WP_Term objects
      
    $term_slugs = array();
      
    $attributeinfo str_replace(', '','$attributeinfo);
      
    $term_names_array explode(','$attributeinfo);
      if(
    reset($term_names_array)){
          foreach( 
    $term_names_array as $term_name ){
              
    // Get the WP_Term object for each term name
              
    $term get_term_by'name'$term_name'pa_xuat-xu');
              
    // Set the term slug in an array
              
    echo  'Url: '.$term->slug.', Name: '.$term->name;
          }
      }

    • Với xuat-xu: là slug của attribute
    Kết quả: Url: bangladesh, Name: Bangladesh
     
    Cảm ơn đã xem bài:

    Get list taxonomy term attribute slug and name woocommerce product



Chủ để tương tự : list taxonomy
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Get Product List by product ids woocommerce như thế nào? 29/3/22
Mã nguồn mở Wordpress Get list Gallery images url from product in woocommerce 28/10/21
Mã nguồn mở Wordpress Get Prodcut list by category id or list id products woocommerce ? 28/10/21
Mã nguồn mở Wordpress ACF get Field Taxonomy Category Product Cat Woocommerce Wordpres như thế nào? 2/6/22