Advertisement
dbranes

stackoverflow.com/a/21435355/2078474

Jan 29th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Testing out WP_TAX_Query
  4.  *
  5.  * @link: http://stackoverflow.com/a/21435355/2078474
  6.  */
  7.  
  8.     $tax_query = array();
  9.     $tax_query[0] = array(
  10.                        'taxonomy'           => 'category',
  11.                        'terms'              =>  array( 65 ),
  12.                        'field'              => 'term_id',
  13.                        'include_children'   => 1
  14.                    );
  15.     $t = new WP_TAX_Query( $tax_query );
  16.     print_r( $t->get_sql( $GLOBALS['wpdb']->posts, 'ID' ) );
  17. ?>
  18.  
  19. Results:
  20.  
  21. Array
  22. (
  23.     [join] =>  INNER JOIN wp_term_relationships ON (tfl_posts.ID = wp_term_relationships.object_id)
  24.     [where] =>  AND ( wp_term_relationships.term_taxonomy_id IN (15,70,75) )
  25. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement