Php WP_查询显示特定类别及其子类别

Php WP_查询显示特定类别及其子类别,php,wordpress,Php,Wordpress,我需要更改WP\u query的行为。目前,它显示了所有主要类别及其子类别,我需要有具体的类别及其类别 例如:ID为1的类别A有10个子类别,我需要显示(过滤类别A和10个子类别) <?php $the_query = new WP_Query( array("post_type"=>"project_post") ); while ( $the_query->have_posts() ) : $the_query->the_post(); $i

我需要更改
WP\u query
的行为。目前,它显示了所有主要类别及其子类别,我需要有具体的类别及其类别

例如:ID为1的类别A有10个子类别,我需要显示(过滤类别A和10个子类别)


<?php
    $the_query = new WP_Query( array("post_type"=>"project_post") );
    while ( $the_query->have_posts() ) : $the_query->the_post();
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'project_preview_big' );
    $image = $image[0];
    $categories = wp_get_post_terms($post->ID,"projects_category");
    $category = array();
    if(count($categories)){
        foreach($categories as $categ){
            array_push($category,$categ->name);
        }
        $category = implode(",",$category);
    }
    else{
        $category = "";
    }
    $cats = array();
    foreach($categories as $cat){
        array_push($cats,$cat->term_id);
    }
    $cats = implode(",",$cats);
?>
<div class="project" style="overflow:hidden;" data-categories='<?php echo $cats; ?>'>
    <img src="<?php echo $image; ?>" width="100%"/>
    <div class="project_box_info">
        <p class="project_category_post"><?php echo $category; ?></p>
        <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
        <p>
        <?php
            $content = excerpt(strip_tags($post->post_content),16,"...");
            echo $content;
        ?>
        </p>
        <a class="read_more" href="<?php the_permalink(); ?>"><?php _e("Prohlédnout projekt","um_lang"); ?> <span></span></a>
    </div>
</div>
<?php
    endwhile; 
?>