admin管理员组文章数量:1133768
This is my first post, I'm a bit stuck.
I have a custom post (dan) and taxonomy (dnas), with hierarchical categories.
I want to make a query resulting in posts at toplevel (hoofdcategorie01, hoofdcategorie02).
I have the following code that gives me al the posts.
<?php
$the_query = new WP_Query( array(
'post_type' => 'dna',
'orderby' => 'title',
'order' => 'ASC',
'tax' => array(
array (
'taxonomy' => 'dnas',
'terms' => $term->term_id,
'field' => 'term_id',
'include_children' => false,
//'terms' => 'politics',
)
),
) );
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<h4><?php the_title(); ?></h4>
<?php
endwhile;
wp_reset_postdata();
?>
What am I doing wrong?
This is my first post, I'm a bit stuck.
I have a custom post (dan) and taxonomy (dnas), with hierarchical categories.
I want to make a query resulting in posts at toplevel (hoofdcategorie01, hoofdcategorie02).
I have the following code that gives me al the posts.
<?php
$the_query = new WP_Query( array(
'post_type' => 'dna',
'orderby' => 'title',
'order' => 'ASC',
'tax' => array(
array (
'taxonomy' => 'dnas',
'terms' => $term->term_id,
'field' => 'term_id',
'include_children' => false,
//'terms' => 'politics',
)
),
) );
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<h4><?php the_title(); ?></h4>
<?php
endwhile;
wp_reset_postdata();
?>
What am I doing wrong?
Share Improve this question asked Oct 2, 2023 at 10:31 DennisDennis 11 Answer
Reset to default 0The problem is this:
'tax' => array(
There is no tax
option in WP_Query
so it's ignored. Did you mean to use tax_query
?
本文标签: Query top level custom post in taxonomy
版权声明:本文标题:Query top level custom post in taxonomy 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736787326a1952928.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论