创建模板以按属性显示产品

时间:2016-05-12 21:18:09

标签: wordpress templates attributes woocommerce product

在WooCommerce中,我创建了一个名为“country”的属性,其中包含两个术语。我使用此术语将此属性添加到我的产品中。

我以这种方式获得了我的条款:

echo '<ul>';
$terms = get_terms( 'pa_country', 'hide_empty=0' );
foreach ($terms as $term) :
    $term_link = get_term_link( $term->slug, 'pa_country' );
    echo '<li><a href="'.$term_link.'" title="'.$term->name.'">'.$term->name.'</a></li>';
endforeach;
echo '</ul>';

但是当我点击链接时,它不使用我的模板(但只重新加载主页)。我的链接是这样的:

/?taxonomy=pa_country&term=usa

因此,在我主题的woocommerce模板文件夹中,我创建了2个模板:

  • 分类法country.php
  • 分类法pa_country.php

但它们不起作用!

有什么想法吗?

感谢您的进步。

0 个答案:

没有答案