Can an array be used as a meta_query value?
Can an array be used as a meta_query value?
Can an array be used as a meta_query value?
This is a bit of a work around, but you could create a Post Meta Block with the Block API, which simply sets a post meta value for a post. Then you could add this block every time you add your ACF custom block, enabling you to query all posts with the ACF custom block. … Read more
I don’t think it’s possible. ACF stores repeater data in separate postmeta fields – one database row for every field in the repeater – so you would have to query multiple fields, and unless you always have the same number of repeater fields, you wouldn’t even know how many to query. It sounds like you … Read more
After fiddling and searching a bit I managed to have: ‘selected’ 10 posts on top ‘remaining’ posts below sorted descending by date Unfortunately the ‘selected’ posts are in descending order … here is my query: $args = array( ‘post_type’ => array( ‘projekty’, ‘publikacje’, ‘wystawy’, ‘wyklady’ ), ‘post_status’ => array( ‘publish’ ), ‘meta_query’ => array( ‘relation’ … Read more
Actually, I don’t think you need that mt1.post_id IS NOT NULL DESC sorting, hence you also do not need to use the posts_orderby hook. You can just use the orderby parameter in WP_Query like so: Also note that, in the first meta query clause named/keyed start_date_value, you should set the type arg to DATE (like … Read more
Do a simple meta_query and compare by meta_value_num. array( ‘post_type’ => ‘webcast’, ‘meta_key’ => ‘webcast-date’, ‘meta_value’ => array( time(), strtotime(‘+60 days’) ), ‘meta_type’ => ‘numeric’, ‘meta_compare’ => ‘BETWEEN’, ‘orderby ‘ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); For an easy example. You can find more complex examples on the site filed under meta-query – even more … Read more
To sort based on a date field, you need to convert the date to a UNIX datetime format. It’s probably best to store the date in a separate custom field. I’ve never had to set this up, but you’d hook into save_post look for a custom field with the date in it convert that to … Read more
You want natural order sorting, Example; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); natsort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.2 5.11 5.12 5.21 Where as; $val = array(5.1, 5.11, 5.12, 5.2, 5.21); asort($val); foreach ($val as $key => $val) { echo $val.”<br>”; } Produces: 5.1 5.11 5.12 5.2 … Read more
The problem is that you’re comparing 10000 and 10 000 as strings, and as such they are not the same value. So, you either need to sanitize the strings to ensure that both return an equivalent value, or you’ll need to force them to be integers, so that they’ll be evaluated as the same value. … Read more
You can do this using WP_Query since 3.1 with a meta_query. $args = array( ‘meta_key’ => ‘_count-views_all’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $sortOrder, ‘posts_per_page’ => 9, ‘paged’ => $paged, ‘meta_query’ => array( ‘relation’ => ‘OR’ array( ‘key’ => ‘contributorid1’, ‘value’ => $id, ‘compare’ => ‘=’ ), array( ‘key’ => ‘contributorid2’, ‘value’ => $id, ‘compare’ => … Read more