WooCommerce:产品属性税务查询问题,未显示任何产品

问题描述

在 Woocommerce 中,我尝试通过 WP_Query 查询产品,这些产品根据显示页面具有特定的产品属性

以下代码显示任何产品:

<div class="container py-5">
  <div class="row">
    <?PHP
    $postid = get_the_ID();
    if ($postid == 48) {
      $sect = 'veiw';
    } elseif ($postid == 148) {
      $sect = 'wall';
    } elseif ($postid == 192) {
      $sect = 'pasio';
    } elseif ($postid == 146) {
      $sect = 'floor';
    } elseif ($postid == 147) {
      $sect = Stairs;
    }
    $query = new WP_Query(array(
      'post_type'      =>
      'product','post_status' => 'publish','posts_per_page' => -1,'tax_query'
      => array(array(
        'taxonomy' => 'pa_usage','terms' => explode(",",$sect),'field' => 'slug','operator' => 'IN'
      ))
    ));
    while ($query->have_posts()) : $query->the_post();
      echo '
    <div class="col-md-3 productgroup text-right pb-4">
      <li>
        <a href="' . get_permalink() . '"
          ><div class="product__preview">
            <img class="img-fluid" src="' . get_the_post_thumbnail_url() . '" />
          </div>
          <span>' . get_the_title() . '</span></a
        >
      </li>
    </div>
    ';
    endwhile;
    wp_reset_postdata(); ?>
  </div>
</div>

我做错了什么?有什么帮助吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)