Meta Query with spaces in value?

Try to pass your multi value in array, example ‘meta_query’ => array( array( ‘key’ => ‘some_key’, ‘value’ => array( “value1 with space”, “value2”, “value3”, ), ‘compare’ => ‘IN’ )

Custom query based on meta key – Reduce three states to two in results?

This can be done by providing a “default” value to the ORDER BY statement. Try adding this before your call new WP_Query($args);: $setDefaultOrderby = function($statement) { return str_replace(‘wp_postmeta.meta_value’, “COALESCE(wp_postmeta.meta_value, ‘false’)”, $statement); }; add_filter(‘posts_orderby’, $setDefaultOrderby); and this after it: remove_filter(‘posts_orderby’, $setDefaultOrderby); Change the ‘false’ with whatever the default value is that you need. I am using … Read more

Meta Query Array Error 500

In my previous answer (that I’ve deleted..), I suggested using custom SQL queries, which worked for me. However, since it didn’t work (well) for you, let’s try using this function: function get_player_stats( $player_id ) { $apps = 0; // Total appearances. $subs = 0; // Total sub-appearances. $goals = 0; // Total goals. // Get … Read more

Setting proper query for multiple custom admin filters

This is my final working piece of code: function wpr_manager_filter($query) { global $pagenow; global $typenow; $current_page = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if ( is_admin() && ‘properties’ == $typenow && ‘edit.php’ == $pagenow ) { $queryParamsCounter = 0; if (isset( $_GET[‘city-filter’] ) && $_GET[‘city-filter’] != ‘-1’) { $cityId = (int)$_GET[‘city-filter’]; $queryParamsCounter++; } if … Read more

Filter WooCommerce Orders query with user meta data

I see 2 possible ways: 1) Using your WP_User_Query in a WC_Order_Query with the customer_id argument this way: // Users query $user_ids = (array) get_users([ ‘role’ => ‘customer’, ‘number’ => – 1, ‘fields’ => ‘ID’, ‘meta_query’ => [ ‘relation’ => ‘OR’, [ ‘key’ => ‘unsubscribed’, ‘compare’ => ‘!=’, ‘value’ => 1 ], [ ‘key’ => … Read more

ACF Date Based wp_query

I’ve modified your existing code.Can you please try the code bellow: $args = array ( ‘post_type’ => ‘exhibitions’, ‘meta_query’=> array( ‘relation’ => ‘AND’, array( ‘key’ => ‘exhibition_status’, ‘value’ => ‘past’, ), array( ‘key’ => ‘end_date’, ‘compare’ => ‘EXISTS’, ‘type’ => ‘DATE’ ), ), ‘meta_key’ => ‘end_date’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, … Read more

Add condition of user capability in WP_query

#SOLVED# Issue is solved by defining the meta_query conditions with an if statement. So if current_user_can(‘subscriber’) the meta_query includes the conditions, otherwise the query includes all posts. This is the code in case this is helpful for anyone else: <?php //create variables $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; … Read more

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