Is it possible to orderby multiple meta_keys when using meta_value_num?

You might want to check out the query improvements in WP 4.2 for ‘orderby’ and ‘meta_query’. Details are on https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query. Try to name your meta_query clauses, then order by them. Following code is untested: $query = array( ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘cat1-clause’ => array( ‘key’ => ‘cat1’, ‘type’ => ‘numeric’ … Read more

Add indexing to meta_value in wp_postmeta

Don’t limit the field, instead, limit the index, e.g. ALTER TABLE wp_postmeta ADD key(meta_value(100)) This limits the index to the first hundred bytes of meta_value. You’ll probably want an index on post_id, meta_key, meta_value for joins. How much of meta_key and meta_value is required depends on your data, for example ALTER TABLE wp_postmeta ADD key(post_id, … Read more

ACF Relationship Field Search Filtering [closed]

First, read this post to understand my answer Search that will look in custom field, post title and post content You may want to use the acf/fields/relationship/query/ however, when adding the args: $args[‘meta_query’] = array(array( ‘key’ => ‘your_meta’, ‘value’ => $args[‘s’], ‘compare’ => ‘LIKE’, )); you will find that using that query, WordPress will search … Read more

WP_Query orderby custom field then post_date in one query

Multiple meta_query arguments with OR You may use the ‘relation’ => ‘OR’ argument in meta_query with two sets of field_order arguments: one with meta_value >= ‘0’ and the other one with NOT EXISTS to generate the main query. ‘meta_query’ => array( ‘relation’ => ‘OR’, field_order’ => array( ‘key’ => ‘field_order’, ‘value’ => ‘0’, ‘compare’ => … Read more

WP_Query with checkbox meta_query

Take a look at the codex for a better understanding of queries of custom fields but it should look something like this: $subjects_array = explode(“_”, $_GET[“subjects”]); $args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘any’, ‘meta_query’ => array( array( ‘key’ => ‘field_name’, ‘value’ => $subjects_array, ‘compare’ => ‘IN’ ) ) ); $query = new WP_Query($args);

Meta Query with AND & OR?

Sorry, doesn’t work that way. The “simple” meta parameters are converted into part of the meta_query as a whole. So it’s not a separate thing, and your OR relation applies to it as well. Your query thus is not possible with the normal query system, because you want to mix ANDs with ORs (you want … Read more

Changing the meta_query of the main query based on custom query_vars and using pre_get_posts

Instead of trying to display all the matching events on your by-date page, you could try to display through ?post_type=event like this: function rewrite_rule_by_date() { add_rewrite_rule(‘by\-date/([0-9]{4}\-[0-9]{2}\-[0-9]{2})$’, ‘index.php?post_type=event&event_date=$matches[1]’, ‘top’); } add_action( ‘init’, ‘rewrite_rule_by_date’ ); function query_var_by_date() { add_rewrite_tag( ‘%event_date%’, ‘([0-9]{4}-[0-9]{2}-[0-9]{2})’); } add_action( ‘init’, ‘query_var_by_date’ ); function custom_event_query( $query ) { if ( get_query_var( ‘event_date’ ) && … Read more

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