【问题标题】:Retrieving Product tag to use in query in Woocommerce检索产品标签以在 Woocommerce 中的查询中使用
【发布时间】:2013-02-26 08:12:25
【问题描述】:

我正在尝试查询与我的产品标签具有相同标签的帖子。 我可以在查询之前打印我的标签(参见第一行代码),它可以工作,但是在查询中一切都出错了。

<?php echo $product->get_tags(); ?>
<?php
 $producttags = get_tags();
 if ($producttags) {
foreach($producttags as $tag) {
    $tag = $tag->slug;  break;
}
query_posts('tag='.$tag.'&posts_per_page=-1');
while (have_posts()) : the_post(); ?>
<div class="actucontent">
  <h3>
    <?php the_title(); ?>
  </h3>
  <?php the_content(); ?>
</div>
<?php endwhile;
wp_reset_query();
}
?>

有什么想法吗?问题是,我不知道如何在我的查询中调用 $product-&gt;get_tags()

【问题讨论】:

    标签: wordpress tags woocommerce


    【解决方案1】:

    get_tags() 是 WP_Post 的成员,而 $product 是 WC_Product_Simple 类型

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-09
      • 1970-01-01
      • 2020-12-07
      • 2016-09-29
      • 2019-06-20
      • 1970-01-01
      • 2015-09-05
      • 2012-08-12
      相关资源
      最近更新 更多