Advertisement
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);
- // The Loop
- if ( $query->have_posts() ) {
- $return=array();
- while ( $query->have_posts() ) {
- $query->the_post();
- $in_tax_array = false;
- foreach($taxarray as $taxarray)
- {
- if ($taxarray==get_the_ID()) {$in_tax_array=true;}
- }
- if ($in_tax_array==true) {
- $return = array_merge($return, array(get_the_ID()));
- }
- }
- return $return;
- } else {
- return array();
- }
- wp_reset_postdata();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement