Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Contractor_model
- {
- function get_ids_from_tax($taxonomy, $taxarray, $operator="IN")
- {
- global $wp_query;
- $args = array(
- 'post_type' => 'contractors',
- 'posts_per_page' => -1,
- 'tax_query' => array(
- array(
- 'taxonomy' => $taxonomy,
- 'terms' => $taxarray,
- 'field' => 'id'
- )
- )
- );
- $query = new WP_Query($args);
- return $query;
- wp_reset_postdata();
- }
- }
- $contractor = new Contractor_model();
- print_r($contrator->get_ids_from_tax('service_type', '$_GET['service_type']'));
- //$_GET['service_type'] returns the following:
- //Array ( [0] => 24 )
- //id #24 for the custom taxonomy service_type does exist, and it has 2 contractors attached to it
- ?>
Advertisement
Add Comment
Please, Sign In to add comment