0

我在下面有这段代码:

<?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> ';
  }
 }
}
?>

在 echo 中,我想添加此代码,以便我们可以从该类别中提取最新帖子。

<?php while (have_posts()) : the_post(); ?>

我知道这是基本的 PHP 但我们将如何添加它?

4

0 回答 0