下面的代码非常适合提取五个随机类别的标题,问题是针对每个随机类别,我想要最新的帖子标题和缩略图,但我在哪里以及如何添加帖子查询?
<?php
//display random sorted list of terms in a given taxonomy
$counter = 0;
$max = 5; //number of categories to display
$taxonomy = \'category\';
$terms = get_terms($taxonomy);
shuffle ($terms);
//echo \'shuffled\';
if ($terms) {
foreach($terms as $term) {
$counter++;
if ($counter <= $max) {
echo \'<p><a href="\' . get_category_link( $term->term_id ) . \'" title="\' . sprintf( __( "View all posts in %s" ), $term->name ) . \'" \' . \'>\' . $term->name.\'</a></p> \';
}
}
}
?>