Regarding your first problem, because $args
is an PHP: array you could do something like this:
Code:
$args = array(
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'custom_post_type',
'post_status' => 'publish',
'posts_per_page' => '150'
);
if ( $catArr ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'tax_type',
'field' => 'id',
'terms' => $catArr
)
);
}
Note: code is exemplary
Regarding your second question, regarding the meta_query
, you should take a look at this: