I use $_POST form to get multiple elements from a form. The main problem is when I have multiple "if statements". It can become a true mess with nested statements when I want to check if multiple strings exist...
$cat = // Categories
if(!empty($cat)) {
$args = array(
'post_type' => 'domains',
'post_status' => 'publish',
'tax_query' => array(
array (
'taxonomy' => 'domain_categories',
'field' => 'slug',
'terms' => $cat, // ELEMENT EXISTS FOR $cat
),
),
);
} else { // ELSE STATEMENT IF $cat DOESN'T EXIST
$args = array(
'post_type' => 'domains',
'post_status' => 'publish',
);
} // END STATEMENT FOR $cat
So, I would like to be able to simplify this.