yokelrobin
11-20-2011, 11:26 PM
I've tried searching for this but I just can't seem to get my head around it, hopefully someone can help.
This is the code I have:
$args = array(
'cat' => 5,
'meta_query' => array(
array(
'key' => '_mf_write_panel_id',
'compare' => '=',
'value' => 1
)
),
'meta_key' => 'number_of_bedrooms',
'orderby' => 'meta_value',
'order' => 'ASC'
);
and I want to turn the array into this:-
$args = array(
'cat' => 5,
'meta_query' => array(
array(
'key' => '_mf_write_panel_id',
'compare' => '=',
'value' => 1
),
array(
'key' => 'swimming_pool',
'compare' => '=',
'value' => 'yes');
),
'meta_key' => 'number_of_bedrooms',
'orderby' => 'meta_value',
'order' => 'ASC'
);
But... I need to add it in after the initial array has been created.
I've tried all sorts of variations of this:-
$args['meta-query'] = array('key' => 'swimming_pool','compare' => '=','value' => 'yes');
and array_push and anything else I can think of but it doesn't seem to be working.
It's to build a Wordpress query, so I need to use conditionals to decide whether to add the extra arrays into the query based on a search form on the preceding page.
Many thanks for any help offered.
This is the code I have:
$args = array(
'cat' => 5,
'meta_query' => array(
array(
'key' => '_mf_write_panel_id',
'compare' => '=',
'value' => 1
)
),
'meta_key' => 'number_of_bedrooms',
'orderby' => 'meta_value',
'order' => 'ASC'
);
and I want to turn the array into this:-
$args = array(
'cat' => 5,
'meta_query' => array(
array(
'key' => '_mf_write_panel_id',
'compare' => '=',
'value' => 1
),
array(
'key' => 'swimming_pool',
'compare' => '=',
'value' => 'yes');
),
'meta_key' => 'number_of_bedrooms',
'orderby' => 'meta_value',
'order' => 'ASC'
);
But... I need to add it in after the initial array has been created.
I've tried all sorts of variations of this:-
$args['meta-query'] = array('key' => 'swimming_pool','compare' => '=','value' => 'yes');
and array_push and anything else I can think of but it doesn't seem to be working.
It's to build a Wordpress query, so I need to use conditionals to decide whether to add the extra arrays into the query based on a search form on the preceding page.
Many thanks for any help offered.