wordpress archive.php,如何在wordpress的archive.php中获取类别产品?

我想在archive-product.php中显示类别(来自taxonomy-product_category)。

获取类别:

水果

草本植物

萨拉德

蔬菜

请看截图我的意思是:

k1ePm.png

当我在archive-product.php中添加代码时:

$args = array(

'post_type' => 'product',

'taxonomy' => 'product_category',

'hierarchical' => 1,

'nopaging' => false,

'posts_per_page' => '2',

'posts_per_archive_page' => '10',

'ignore_sticky_posts' => true,

'order' => 'rand',

);

echo '

';

echo '

';

// The Query

$query = new WP_Query( $args );

// The Loop

if ( $query->have_posts() ) {

while ( $query->have_posts() ) {

$query->the_post();

echo '

';

echo '';

if ( has_post_thumbnail() ) {

the_post_thumbnail(array(486,226));

}

the_title();

the_content();

echo '';

echo '

';

}

} else {

// no posts found

echo wpautop( 'Sorry, no posts were found' );

}

echo '

';

echo '

';

// Previous/next post navigation.

previous_post_link( '%link', 'Prev post in category', true

);

next_post_link( '%link', 'Next post in category', true );

// Restore original Post Data

wp_reset_postdata();

?>

但不显示类别(水果、香草、沙拉、蔬菜)

有人知道吗?

谢谢,

肖恩。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值