我在上使用此代码single.php
, 此查询工作正常,但当post有父项(父项也有子项)时,这会给出输出all posts of parent & children
但在这种情况下,我希望它只查询父术语帖子。
<?php
$post_terms = wp_get_object_terms($post->ID, \'serial\', array(\'fields\'=>\'ids\'));
$args = array(
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1,
\'tax_query\' => array(
array(
\'taxonomy\' => \'serial\',
\'field\' => \'id\',
\'terms\' => $post_terms,
),
)
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
the_title();
}
} else {
}
wp_reset_postdata();
?>
如何根据附加条款查询帖子,仅根据附加条款(当帖子有父条款时不检查子条款)?