term_id; } } } if( $post_type == 'post' ) $args = array('category__in' => $categories); else $args = array('tax_query' => array( array( 'taxonomy' => $taxonomies, 'field' => 'term_id', 'terms' => $categories, ), ),); if($number_posts == 0) { $query = new WP_Query(); return $query; } $args = wp_parse_args($args, array( 'posts_per_page' => $number_posts, 'post__not_in' => array($post_id), 'ignore_sticky_posts' => 0, 'meta_key' => '_thumbnail_id', 'post_type' =>$post_type, 'operator' => 'IN' )); $query = new WP_Query($args); wp_reset_postdata(); return $query; }