Meta_query with or without value

check if the $GET[‘rating’] is set ( isset($_GET[‘rating’]) or has any value. ( !empty($_GET[‘rating’]) if not, build the query fecthing all post without ‘meta_query’ for example: if ( (isset($_GET[‘rating’]) && !empty($_GET[‘rating’]) ) { // restrict $meta[] = array(( ‘key’ => ‘rating’, ‘value’ => $_GET[‘rating’] ); } if ( (isset($_GET[‘tax’]) && !empty($_GET[‘tax’]) ) { $meta[] = … Read more

How can I combine meta_query queries?

Using your constructed array, I think this is the correct syntax: $meta_query_args = array( ‘meta_key’ => ‘price’, ‘meta_value_num’ => 1000, ‘meta_compare’ => ‘<=’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘roomcount’, ‘value’ => 3, ‘type’ => ‘numeric’, ‘compare’ => ‘>=’ ), array( ‘key’ => ‘bathroomcount’, ‘value’ => 2, ‘type’ => ‘numeric’, ‘compare’ => … Read more

Order By Multiple Meta Fields

One problem with the query is that the self-join with the ambiguous WHERE gives you a crossed dataset (which is masked by the DISTINCT), so it would be simpler to use wp_post as a base to attach the joins that precisely match the keys, eg SELECT p.ID, key1.meta_value as prog_ongoing, key2.meta_value as prog_date_start FROM $wpdb->posts … Read more

exclude custom post type by meta key in wp_query

If you don’t use any other meta data, just add the following to your $args: ‘meta_key’ => ‘sold’, ‘meta_value’ => true, // or whatever it is you’re using here ‘meta_compare’ => ‘!=’, Otherwise, use a WP_Meta_Query: ‘meta_query’ => array( array( ‘key’ => ‘sold’, ‘value’ => true, // or whatever it is you’re using here ‘compare’ … Read more

How to use meta_query to check if a meta field has something set?

I figured it out, meta_query must be an array within an array as it is intended for advanced queries using ‘relation’. meta_query => array ( array ( //’relation’ => ‘OR’, ‘key’ => ‘audio_file’, //The field to check. ‘value’ => ”, //The value of the field. ‘compare’ => ‘!=’, //Conditional statement used on the value. ), … Read more

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