wordpress随机调用指定分类ID下的内容
34
以下代码可以实现,在任意位置调用指定分类ID为666的10条内容
<?php
$cat = get_the_category();
foreach($cat as $key=>$category){
$catid = $category->term_id;
}
$args = array(‘showposts’ => 10,’cat’ => ‘666’ );
$query_posts = new WP_Query();
$query_posts->query($args);
while ($query_posts->have_posts()) : $query_posts->the_post();
?>
<div class=”col-md-4 wow fadeInUp” data-wow-delay=”0.<?php echo($cmntCnt++); ?>s”>
<div class=”border-bottom mt-2 pb-2″>
<i class=”fa fa-angle-right”></i> <a href=”<?php the_permalink() ?>”><?php the_title(); ?></a>
</div>
</div>
<?php endwhile;?>
<?php wp_reset_query(); ?>