找到了解决方案。
我找到了一个函数来回答我的问题。
功能如下:
function get_category_by_letter($letter) {
$args=array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0);
$categories=get_categories($args);
foreach($categories as $category) {
$catname = $category->name;
$first_letter = substr(strip_tags($catname), 0 , 1);
if(strcasecmp($first_letter,$letter) != 0) continue;
else {
$cats[] = $category->term_id;
$cats[] = $category->name;
}
}
return $cats;
}