Get closest event where meta_key field is an array
Get closest event where meta_key field is an array
Get closest event where meta_key field is an array
There is no difference in terms of the “final” query. The former was the “old” way of querying post meta, before WP_Meta_Query was introduced with support for more complex queries. WP_Query::get_posts() now simply translates meta_key/value arguments into the new format with WP_Meta_Query::parse_query_vars(). Use whichever format you feel suits best for the task.
One of the options would be to sort at a database level by a dynamically calculated column. This is too complex for me. Having your task on production I would probably create a third meta key: ‘division’ derivated from the two and update its value on every post save. Then I would sort by this … Read more
Just remove the ID then. $images = get_the_author_meta( ‘images’, $user->ID ); $images = explode(‘,’,$images); $images is an Array isn’t it? Then I hope this one can help you. https://stackoverflow.com/questions/2448964/php-how-to-remove-specific-element-from-an-array
meta query always fails even if data is correct
OK, I have made a basic error here. I have hooked into parse_query and made the array blank if certain paramenters are met, which they where here. Thanks for your help guys, you led me to where to look.
WP search in metadata post
You may be able to use the LIKE operator: $meta_args[] = array( ‘key’ => ‘availability’, ‘value’ => $availability, ‘compare’ => ‘LIKE’ ); In the codex you can see a list of comparison operators.
I managed to sort the problem out myself with a fresh set of eyes but thought it would be useful for others if they find themselves with a similar issue in future. If the answer needs tidying please feel free to suggest any edits. I had to edit a few lines of code in order … Read more
You might be missing the ‘meta_key’ arg here: $args = array( ‘ignore_sticky_posts’=> 1, ‘meta_key’ => ‘wpl_location’, // here ‘post_type’ => ‘post_projects’, ‘meta_query’ => array( array( ‘key’ => ‘wpl_location’, ‘value’ => ‘Europe’, ‘compare’ => ‘IN’, ), ), ); source: https://codex.wordpress.org/Class_Reference/WP_Query (about three quarters down the page).