Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获得商业产品的大量标签_Php_Wordpress_Woocommerce_Product - Fatal编程技术网

Php 获得商业产品的大量标签

Php 获得商业产品的大量标签,php,wordpress,woocommerce,product,Php,Wordpress,Woocommerce,Product,我试图得到我的产品标签的名字。像这样 $args = array( 'post_type' => 'product'); $list_tags = []; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $tag = get_the_term_list($post->ID, 'product_tag', '', ',' ); array_pu

我试图得到我的产品标签的名字。像这样

   $args = array( 'post_type' => 'product');
$list_tags = [];
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
  $tag = get_the_term_list($post->ID, 'product_tag', '', ',' ); 
  array_push($list_tags, $tag );
endwhile;
return $list_tags;
我获得了我的标签列表,但我想要这个标签的slug

有什么想法吗

$args = array( 'post_type' => 'product');
$list_tags = array()
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    $terms = get_the_terms( $post->ID, 'product_tag' );;
    if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
        foreach ( $terms as $term ) {
            $list_tags = $term->slug;
            array_push($list_tags, $terms );
        }
    }
endwhile;
return $list_tags;
基于: