Advanced WP Query hogs the SQL server

There are several options: Use some Lucene-based search index and cache your queries there. Power it with lots of RAM so nothing hits your DB after the first query. Use something like… Elasticsearch Solr Sphinx Do not attempt to run Lucene plain … you will find yourself in hell. Nobody does that for a good reason. … Read more

Use meta_query to display events by date in custom field

Simpler CODE: Logically, when you check >= for both _event_start_date and _event_end_date, that automatically covers the BETWEEN check. So the following CODE should work: $termName = get_queried_object()->name; $termSlug = get_queried_object()->slug; $event1 = current_time( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘event’, ‘event-categories’ => $termSlug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 10, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more

Comparing arrays with meta_query in pre_get_posts

The ACF Documentation recommends checking the values individually rather than simultaneously using an array. The following code is from the ACF Documentation for the Checkbox field type: http://www.advancedcustomfields.com/resources/field-types/checkbox/ /* * Query posts for a checkbox value. * This method uses the meta_query LIKE to match the string “red” to the database value a:2:{i:0;s:3:”red”;i:1;s:4:”blue”;} (serialized array) … Read more

meta_query date and time comparisons

You are mixing up an older meta syntax with the newer one. I’d suggest you clean that up for readability and for potential compatibility in the future. (WordPress does seem to parse the mixed query correctly though) $args = array( ‘posts_per_page’ => -1, ‘post_type’ => MDJM_EVENT_POSTS, ‘post_status’ => ‘mdjm-approved’, ‘meta_query’ => array( ‘relation’ => ‘AND’, … Read more

How loop through posts based on custom fields

To select posts that have a meta value, use the EXISTS comparison operator. $args = array( ‘post_type’ => ‘jobs’, ‘posts_per_page’ => 12, ‘paged’=> $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘job_category’, ‘field’ => ‘slug’, ‘terms’ => $term->slug, ) ), ‘meta_query’ => array( array( ‘key’ => ‘_shop’, ‘compare’ => ‘EXISTS’ ) ) );

meta_key and meta_value not working together

You could try this: $args = array( ‘post_type’ => ‘cqpp_interventions’, ‘posts_per_page’ => ‘-1’, ‘meta_query’ => array( array( ‘key’ => ‘priority’, ‘value’ => ’80’ ) ) ); The real issue with your query is because you are passing meta_key and meta_value. However, the arrays in your meta_query argument should have the keys key and value instead. … Read more

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