Restrict WordPress search to a single ACF field

I ended up using a simple meta_query: $args = [ ‘post_status’ => ‘publish’, ‘post_type’ => $post_type, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘my_acf_field’, ‘value’ => $search_term, ‘compare’ => ‘LIKE’ ), ) ]; $query = new WP_Query($args);

Display posts every specific day

You need to specify the return-format of the acf-field as ‘l’ & then modify your query as follows: $todayName = date(‘l’); $schedules = new WP_Query([ ‘posts_per_page’ => -1, ‘post_type’ => ‘serie’, ‘meta_query’ => [ ‘relation’ => ‘AND’, [ ‘key’ => ‘status’, ‘value’ => ‘1’, ‘compare’ => ‘=’, ], [ ‘key’ => ‘release_date’ , ‘value’ => … Read more

How to create better WP_Query to look for date time which is anywhere between two meta values?

You might want to do this for querying between two dates: $query = new WP_Query(array( ‘post_type’ => ‘rezervacija’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘start_date’, ‘value’ => current_time(‘Ymd’), //change this according to your need. ‘compare’ => ‘>=’, ), array( ‘key’ => ‘end_date’, ‘value’ => current_time(‘Ymd’), //change … Read more

Getting posts by custom field value

first, you have to loop through all posts that have this meta key (your custom field) and then update post meta with replacing the word (from) to leave the number alone in the meta value. //paste the following code in your plugin or theme functions.php add_action( ‘init’, function () { if ( ! get_option( ‘prefix_correct_data’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)