How can I do a variable for meta_query?
Use a ternary operation to keep it trim. array( ‘key’ => ‘rob_value’, ‘value’ => $rob, ‘compare’ => ( empty( $rob ) ? ‘!=’ : ‘=’ ) ); Breakdown, incase you’ve not seen ternary operators before.. array( ‘key’ => ‘rob_value’, ‘value’ => $rob, ‘compare’ => ( // If empty( $rob ) // Then ? ‘!=’ // … Read more