如果所有帖子都显示在同一页上,那么很容易做到:
$AZposts = get_posts(array(
\'numberposts\' => -1,
\'post_type\' => \'post\',
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'category\' => $cat
));
$current = "";
$nav = "";
$postlist = "";
foreach($AZposts as $AZpost) {
$firstletter = strtoupper(substr($AZpost->post_title,0,1));
if($firstletter != $current) {
$postlist .= "<b><a name=\'$firstletter\'> $firstletter </a></b><br>\\n";
$nav .= "<a href=\'#$firstletter\'> $firstletter </a> ";
$current = $firstletter;
}
$postlist .= $AZpost->post_title . "<br>\\n";
}
print $nav . "<br>" . $postlist;