Posted By

crypticsoft on 03/01/12


Tagged

post wordpress type taxonomy WPQuery


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

srdjan
danfolt


WordPress Query Taxonomy by ID


 / Published in: PHP
 

When you create a custom post type and need to query by ID then you can pass in the 'field' and the 'terms' with the ID for that post type.

  1. $args = array('post_type'=>'bbfitness_exercises',
  2. 'tax_query' => array(
  3. 'taxonomy' => 'bbfitness_exercises_types',
  4. 'field' => 'id',
  5. 'terms' => $etype
  6. )
  7. )
  8. );
  9.  
  10. // The Query
  11. $the_query = new WP_Query( $args );
  12. $result = $the_query->posts;

Report this snippet  

You need to login to post a comment.