调用 WP调用指定类别下的分类
<ul>
<?php
$args = array(
'post_type' => 'products',
'orderby' => 'ID',
'order' => 'ASC',
'hide_empty' => false,
'number' => 4,
'include' => array(3,4,5,6),
);
$terms = get_terms($args);
//print_r($terms ) ;
$count = count($terms);
foreach ( $terms as $term ) {
?>
<li>
<a class="R-box" href="<?php echo get_category_link($term->term_id) ; ?> ">
<div class="R-box-img">
<img src="<?php echo @z_taxonomy_image_url($term->term_id); ?>" alt="<?php echo $term->name;?>">
</div>
<div class="R-box-tt"><?php echo $term->name;?></div>
</a>
</li>
<?php } ; ?>
<button class="r-more"> > </button>
</ul>
调用当前类别下的文章
// 获取当前分类的ID
$category_id = get_queried_object_id();
// 获取当前分类下的所有文章
$args = array(
'cat' => $category_id,
'posts_per_page' => 1,
);
$posts = new WP_Query($args);