In looking at the WP_Tax_Query
class in /wp-includes/taxonomy.php
, I found that there is a ‘include_children’ option which defaults to true. I modified my original get_posts()
call with the following, and it works great:
1 2 3 4 5 6 7 8 9 10 11 12 | $pages = get_posts(array( 'post_type' => 'page', 'numberposts' => -1, 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'term_id', 'terms' => 1, /// Where term_id of Term 1 is "1". 'include_children' => false ) ) )); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.