The following code filters posts from the database by certain fields.
array('key' => 'telephone', 'value' => '0','compare' => '>')
Some other factors determine if there might be another array here. The problem is the code required to work that out will return a variable. $filters;
Is this possible
$filters = array('key' => 'mobile', 'value' => '0','compare' => '>')
array('key' => 'telephone', 'value' => '0','compare' => '>') . $filters
And if not how could this work.
CLARIFICATION
This is the structure that the function would require this to be in.
'meta_query' => array(
array('key' => 'telephone', 'value' => '0','compare' => '>'),
array('key' => 'mobile', 'value' => '0','compare' => '>')
)
But we can’t write it out like that as other factors determine what these queries will be. We have to get something like a variable containing the arrays to go inside the ‘meta_query’ array.
I assume that you are trying to pass it multiple filters in a single array.
Using
.won’t work because that is a string concatenation operation.Use this for an array of arrays:
To get the right format for the function simply: