我想在产品详细信息页面中为产品创建一个类别循环。(在产品下方)。这些产品将来自与产品项相同的类别。
普通类别参数似乎与标准Wordpress参数不一样。WPEC的自定义模板标记(如wpsc_print_category_image()
或wpsc_print_category_name();
)似乎在自定义设置中不起作用。
下面是我尝试做的一个例子
<?php
$args = array( 'post_type' => 'wpsc-product','posts_per_page' => 999, 'orderby'=>'title','order'=>'ASC','category_id'=>'5' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
//the_title();
echo '<div class="isotope-item box default_product_display product_view_';
echo wpsc_the_product_id();
echo '">';
echo '<img src="';
echo wpsc_the_product_image();
echo '"/>';
?>
<div class="prod-info-container">
<div class="prod-info">
<h3 class="prodtitle entry-title">
<?php if(get_option('hide_name_link') == 1) : ?>
<?php echo wpsc_the_product_title(); ?>
<?php else: ?>
<?php echo wpsc_the_product_title(); ?>
<?php endif; ?>
</h3>
<p>
<?php echo the_excerpt(); ?>
</p><!--close wpsc_description-->
<a class="view-detail" href="<?php the_permalink();?>">view</a>
</div>
</div>
<?php
echo '</div>';
endwhile;
?>
这给了我所有的产品,但我想只限于一个类别。
谢谢。
这就是我最终要做的:
$category = get_the_category();
$wpsc_product_category = get_the_product_category( wpsc_the_product_id() );
$curr_cat = $wpsc_product_category[0]->slug;