我想获取当前存档页的slug。我有一个滑块,我想在其中回应这一类别中的产品。几个小时后,这就是我的全部,但它不起作用。。。
<?php
if ( is_single() ) {
$cats = get_the_category();
$cat = $cats[0]; // let\'s just assume the post has one category
}
else { // category archives
$cat = get_category( get_query_var( \'cat\' ) );
}
$cat_name = $cat->name;
$cat_slug = $cat->slug;
echo \'<h2 style="text-align:center;">\'.$cat_name.\' - Spotlight</h2>\';
echo \'<h2 style="text-align:center;">\'.$cat_slug.\' -- Slug</h2>\';
echo "here: ".$cat_name." - ".$cat_slug;
echo do_shortcode(\'[wpb-product-slider title="" product_type="category" category="\'.$cat_slug.\'" items="3" items_desktop="3" items_desktop_small="3" items_tablet="2" items_mobile="1" width="320" height="300" crop="true" theme="ben-box" posts="50" orderby="rand" speed="2000" order="ASC"]\'); ?>
但美元猫总是空的。我该怎么做?