Wordpress 创建模板以按属性显示产品
在WooCommerce中,我创建了一个名为“国家”的属性,其中包含两个术语。我使用此术语将此属性添加到我的产品中 我通过以下方式获得我的条款:Wordpress 创建模板以按属性显示产品,wordpress,templates,attributes,woocommerce,product,Wordpress,Templates,Attributes,Woocommerce,Product,在WooCommerce中,我创建了一个名为“国家”的属性,其中包含两个术语。我使用此术语将此属性添加到我的产品中 我通过以下方式获得我的条款: echo '<ul>'; $terms = get_terms( 'pa_country', 'hide_empty=0' ); foreach ($terms as $term) : $term_link = get_term_link( $term->slug, 'pa_country' ); echo '<
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>';
因此,在我的主题的woocommerce templates文件夹中,我创建了两个模板:
- taxonomy-country.php
- taxonomy-pa_country.php
感谢您的帮助。已解决!!!在管理中,编辑属性并确保其设置为“public”。有一个复选框。我不需要创建任何模板,因为使用archive-product.phpSolved!!!在管理中,编辑属性并确保其设置为“public”。有一个复选框。我不需要创建任何模板,因为使用archive-product.php
/?taxonomy=pa_country&term=usa