meta_query and array of kets
-
I’m trying to build the meta_query part of my args using using an array as it could be one condition or many.
I’m having a bit of block with an issue regarding the array so if anyone has has any thoughts it would be gratefully received. Thanks$query = array(); $query[] = array( 'key' => 'surgical_speciality', 'value' => 'BREAST', 'compare' => 'LIKE' ); $query[] = array( 'key' => 'scientific_surgery', 'value' => 'randomized-clinical-trials', 'compare' => 'LIKE' );The problem is when I add the array to the meta_query I get an unwanted index on the array that breaks the query.
Array ( [post_type] => post [category_name] => scientific-surgery [posts_per_page] => 36 [paged] => 0 [meta_query] => Array ( [relation] => AND [0] => Array ( [0] => Array ( [key] => scientific_surgery [value] => randomized-clinical-trials [compare] => LIKE ) [1] => Array ( [key] => surgical_speciality [value] => BREAST [compare] => LIKE ) ) ) )I want this:
Array ( [post_type] => post [category_name] => scientific-surgery [posts_per_page] => 36 [paged] => 1 [meta_query] => Array ( [relation] => AND [0] => Array ( [key] => scientific_surgery [value] => randomized-clinical-trials [compare] => LIKE ) [1] => Array ( [key] => surgical_speciality [value] => breast [compare] => LIKE ) ) )The blog I need help with is: (visible only to logged in users)
-
Hi there,
I’m afraid we’re not able to help with this, as we don’t provide any custom code support on WordPress.com, regardless whether your site is hosted with us or somewhere else.
If this custom query is for use in a particular plugin you have installed on your site, please contact support for that plugin directly.
Otherwise you can ask in the advanced forums on WordPress.org, or else try Stackoverflow or the WordPress Stackexchange forums:
https://wordpress.org/support/forums/wp-advanced/
https://wordpress.stackexchange.com/
When posting there, make sure to include some context on what this code is for, as it’s not really clear what you’re trying to do with this code.
Also note that your plan gives you access to both live chat and direct email support with your WordPress.com site. You can reach those at any time by clicking the Help icon that appears bottom-right on all the My Sites pages, or else via the direct link at https://wordpress.com/help/contact. But we won’t be able to assist with custom development work there either.
- The topic ‘meta_query and array of kets’ is closed to new replies.