WordPress Query Taxonomy by ID


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments


You need to login to view comments.