Php Wordpress获取特定类别的子类别列表
我需要获取特定父类别的子类别列表 我使用了:Php Wordpress获取特定类别的子类别列表,php,wordpress,Php,Wordpress,我需要获取特定父类别的子类别列表 我使用了: wp_list_categories() 但它输出的不是我想要的。它只输出第一个父类别,没有任何兄弟/子类别 我还尝试了输出对象的get_categories() 情景: 我有ParentCategory1,其中有10个childCategory 现在,我想使用以下示例获取这些孩子的列表: wp_get_cats(array("parent"=>"ParentCategory1")); 您需要使用参数从wp_list_categories
wp_list_categories()
但它输出的不是我想要的。它只输出第一个父类别,没有任何兄弟/子类别
我还尝试了输出对象的get_categories()
情景:
我有ParentCategory1
,其中有10个childCategory
现在,我想使用以下示例获取这些孩子的列表:
wp_get_cats(array("parent"=>"ParentCategory1"));
您需要使用参数从wp_list_categories之类的函数中获得所需的结果
以下是我认为是您需要的最佳参数。确保在“的子项”中指定父类别ID
wp_list_categories( array(
'hide_empty' => 0, // show empty categories in the list
'child_of' => enter-ID-here // Replace with the ID of the parent category
) );
我猜你以前只看到过一个类别,因为其他类别都是空的
进一步阅读wp\u列表\u类别
:
更新:
在您的场景中,请参考ParentCategory1。使用上面的示例,您可以找到ParentCategory1(整数)的ID并使用它。您需要使用参数从类似于wp\u list\u categories的函数中获得所需的结果
以下是我认为是您需要的最佳参数。确保在“的子项”中指定父类别ID
wp_list_categories( array(
'hide_empty' => 0, // show empty categories in the list
'child_of' => enter-ID-here // Replace with the ID of the parent category
) );
我猜你以前只看到过一个类别,因为其他类别都是空的
进一步阅读wp\u列表\u类别
:
更新:
在您的场景中,请参考ParentCategory1。使用上面的示例,您可以找到ParentCategory1(整数)的ID并使用它