Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress获取特定类别的子类别列表_Php_Wordpress - Fatal编程技术网

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并使用它