最后,我这样解决了这个问题:
$hg_categories = get_categories();
foreach($hg_categories as $hg_category) {
echo \'<h3>\' . $hg_category -> name . \'</h3>\';
$hg_posts = get_posts(array(\'numberposts\' => -1, \'category\' => $hg_category -> cat_ID));
foreach ($hg_posts as $hg_post) {
if ($hg_post -> ID == get_the_ID()) {
echo \'<li class = "current-post"><a href = "\';
} else {
echo \'<li><a href = "\';
}
echo get_permalink ($hg_post -> ID);
echo \'">\';
echo $hg_post -> post_title;
echo \'</a></li>\';
}
}
如果有更好的解决方案,请告诉我,谢谢。