阿里云服务器

woocommerce是非常不错的商城插件,WordPress配合woocommerce可以搭建出很棒的商城。

在制作模板的时候,常常需要自定义调用woocommerce的分类数据,通过下面方法可以轻松调用出来:

<?php	  	  
$args = array(
    'number'     => $number,
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
    'include'    => $ids
);
 
$product_categories = get_terms( 'product_cat', $args );
 
$count = count($product_categories);
if (function_exists('z_taxonomy_image_url'))
if ( $count > 0 ){
     echo "";
     foreach ( $product_categories as $product_category ) {echo '<div class="item"><div class="line1"></div><div class="pic"><a href="'  . get_term_link( $product_category ) . '"><img src="'.z_taxonomy_image_url( $product_category->term_id  ).'"/></a></div><div class="font1"><a href="'  . get_term_link( $product_category ) . '">' . $product_category->slug . '<br/><span>' . $product_category->name . '</span></a></div></div>';
     }
     echo "";
 }
	  
?>
	  	

上面的代码调用了分类的缩略图片,需要配合分类缩略图插件:Categories Images 

来使用。

相关阅读:
  • WordPress无用数据清理插件:WPDBSpringClear