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’ )
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’ )
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
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
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
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
So, I need to run a Tax query inside a Meta query clause. This does not seem to be possible with the ‘meta_query’ argument, something like this: Correct, what you want to do is not possible using the parameters of WP_Query while keeping your data stored as is. The query is already very expensive/slow to … Read more
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
#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
WordPress will serialize arrays when saving to post meta. The data stored under the key _employer_socials in your example looks like this: Array ( [0] => Array ( [network] => facebook [url] => # ) [1] => Array ( [network] => twitter [url] => # ) [2] => Array ( [network] => linkedin [url] => … Read more
But once I try to look for other meta values, the return bring all members in the DB. Are you sure the meta other than name did not work, i.e. all members/users were returned? Because as I could see it, for your keywords, country and disciplines meta, so long as your compare value is good, … Read more