Php 如何在post中仅显示子目录

Php 如何在post中仅显示子目录,php,wordpress,post,Php,Wordpress,Post,这是我的代码,我想显示特定类别的子类别 <?php wp_dropdown_categories('orderby=name&hide_empty=0&exclude=1&hierarchical=1'); ?> 它显示所有类别和子类别,但我只想显示特定类别的子类别(子类别) 请帮帮我 您的答复将对我非常有帮助。以下是一个示例: <?php $parent_category_id = 12; $args = array(

这是我的代码,我想显示特定类别的子类别

<?php
wp_dropdown_categories('orderby=name&hide_empty=0&exclude=1&hierarchical=1');  
?>

它显示所有类别和子类别,但我只想显示特定类别的子类别(子类别) 请帮帮我

您的答复将对我非常有帮助。

以下是一个示例:

<?php
    $parent_category_id = 12;
    $args = array(
    'orderby'            => 'name',
    'order'              => 'DESC',
    'hide_empty'         => 1,
    'exclude'            => '1',
    'child_of'           => $parent_category_id,
    'hierarchical'       => 1,
    'taxonomy'           => 'category',
    'hide_if_empty'      => false,
);
wp_dropdown_categories( $args ); ?>

这将显示类别12的所有子类别 文档链接-

$args=array('child\u of'=>17);
$categories=get_categories($args);
foreach($categories作为$category){
回声“类别:

”; 回显“Description:”.$category->Description.“

”; 回显“Post Count:”.$category->Count.

”; }
$args = array('child_of' => 17);
$categories = get_categories( $args );
foreach($categories as $category) { 
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) .'" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
echo '<p> Description:'. $category->description . '</p>';
echo '<p> Post Count: '. $category->count . '</p>';  
}