$args = array(
"type" => "post",
"orderby" => "name",
"order" => "ASC");
$types = get_categories($args);
执行时。 $types 只包含“Uncategorized”,因为它被用作我帖子的默认值。还有其他类别可用,但除非我有使用它们的帖子,否则不会返回它们。 如何返回所有可能的类别,而不仅仅是正在使用的类别?
最佳答案
<?php $args = array("hide_empty" => 0,
"type" => "post",
"orderby" => "name",
"order" => "ASC" );
$types = get_categories($args);
?>
关于php - get_categories() 只返回正在使用的类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11154928/