Php WooCommerce将产品类别添加为产品循环中的类
我在一家小型商业商店工作,我想有一个分拣功能。 排序就像一个符咒,但它是基于产品类的排序。 因此,我想将产品类别作为类发布在我的产品循环的列表项上。 我的循环如下所示:Php WooCommerce将产品类别添加为产品循环中的类,php,wordpress,woocommerce,product,Php,Wordpress,Woocommerce,Product,我在一家小型商业商店工作,我想有一个分拣功能。 排序就像一个符咒,但它是基于产品类的排序。 因此,我想将产品类别作为类发布在我的产品循环的列表项上。 我的循环如下所示: <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 999 ); $loop = new WP_Query( $args ); if ( $loop->have_p
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 999
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
woocommerce_get_template_part( 'content', 'product' );
endwhile;
}
else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
<li class="post-15 product type-product status-publish hentry first instock">
<a href="http://shop.bbpixelz.dk/product/i-phone-ai-template/">
<img width="150" height="150" src="http://shop.bbpixelz.dk/wp-content/uploads/2014/01/iphone-ai-template-150x150.png" class="attachment-shop_catalog wp-post-image" alt="iphone-ai-template">
<h3>I-Phone Vector Template</h3>
<span class="price"><span class="amount">$2</span></span>
</a>
<a href="/?add-to-cart=15" rel="nofollow" data-product_id="15" data-product_sku="ai-iphone" class="add_to_cart_button button product_type_simple">Add to cart</a>
</li>
它输出每个项目的列表项,如下所示:
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 999
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
woocommerce_get_template_part( 'content', 'product' );
endwhile;
}
else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
<li class="post-15 product type-product status-publish hentry first instock">
<a href="http://shop.bbpixelz.dk/product/i-phone-ai-template/">
<img width="150" height="150" src="http://shop.bbpixelz.dk/wp-content/uploads/2014/01/iphone-ai-template-150x150.png" class="attachment-shop_catalog wp-post-image" alt="iphone-ai-template">
<h3>I-Phone Vector Template</h3>
<span class="price"><span class="amount">$2</span></span>
</a>
<a href="/?add-to-cart=15" rel="nofollow" data-product_id="15" data-product_sku="ai-iphone" class="add_to_cart_button button product_type_simple">Add to cart</a>
</li>
我想将产品类别作为一个类添加到li中。这是如何实现的?这些类是由WordPress函数生成的,如
content product.php
模板所示:
<li <?php post_class( $classes ); ?>>
这些类由WordPress函数生成,如
content product.php
模板所示:
<li <?php post_class( $classes ); ?>>
这些类由WordPress函数生成,如
content product.php
模板所示:
<li <?php post_class( $classes ); ?>>
这些类由WordPress函数生成,如
content product.php
模板所示:
<li <?php post_class( $classes ); ?>>
这可能应该是
$category->slug
,因为名称并不总是保证是CSS安全的选择器。这可能应该是$category->slug
,因为名称并不总是保证是CSS安全的选择器。这可能应该是$category->slug
,因为名称并不总是保证是CSS安全的选择器。这可能应该是$category->slug
,因为名称并不总是保证是CSS安全的选择器。