Query by 2 values of a repeater ACF field

I know this is an old question, but I thought I’d post the answer in case anybody else is facing the same problem. functions.php: function add_cond_to_where( $where ) { //Replace showings_$ with repeater_slug_$ $where = str_replace(“meta_key = ‘showings_$”, “meta_key LIKE ‘showings_%”, $where); return $where; } add_filter(‘posts_where’, ‘add_cond_to_where’); Query: //Replace showings_$ with repeater_slug_$ //Replace _discounts with … Read more

Revolution Slider Orderby Two Custom Fields

To order by event-end date or start date, your write separate function and call them as per requirement. For example if user clicks on order by start then start function should be called. switch($orderby){ case: ‘event-start’: # your code /* $query[‘meta_key’] = ‘event_start_date’; $query[‘orderby’] = ‘event_start_date’; */ break; case ‘event-end’: #your code /* $query[‘meta_key’] = … Read more

Count custom post types with a specific meta value

1st. you need to add post_type to your query, then you need to filter meta_value with LIKE. Finaly, you need to add posts_per_page as -1 to get ALL posts. $args = array( ‘post_type’=> ‘books’, ‘meta_query’ => array( array( ‘key’ => ‘book_type’, ‘value’ => ‘Fiction’, ‘compare’ => ‘LIKE’, ) ), ); $query = new WP_Query($args); $fiction … Read more

Advanced custom field – gallery – display one random image

Shouldn’t you be doing something like this? <img src=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“alt’]; ?>” /> Update I’m not really familiar with that plugin (stuff could be happening behind the scenes) but here’s a better guess than my previous one: <?php $gallery = get_field(‘gallery_home’); $rand = array_rand($gallery, 1); if( $gallery ): ?> <img src=”https://wordpress.stackexchange.com/questions/99655/<?php … Read more