Appending to existing WP_Query’s meta_query if exists

You can use the WP_Query::get method to get whatever is in the meta query like this: add_action(‘pre_get_posts’,’add_another_meta_query’); function add_another_meta_query($query){ //Be sure to only use the main query on frontend if($query->is_main_query() && !is_admin()){ $meta_query = $query->get(‘meta_query’,array()); $new_meta_query = array(); //now, $meta_query has the meta_query if set (or an array) //check if the old version of meta_query … Read more

User Meta Value not echoing despite Var_Dump Showing correct string

The $havemeta variable isn’t defined inside your shopping_location_text() function, so it isn’t available for use there. For a quick fix (or for testing/toying) you can move your code inside the function, like this: add_action( ‘woocommerce_before_main_content’, ‘shopping_location_text’, 10 ); function shopping_location_text() { global $current_user; get_currentuserinfo(); // wordpress global variable to fetch logged in user info $userID … Read more

Check if searched number is within the post meta value

Assuming your “property-guests” taxonomies have names like “1”, “2”, “3”, etc.: <?php // Get the number of guests the visitor searched for $requiredGuests = $_POST[‘guests’]; // Get all terms in the “property-guests” taxonomy // (By default, this will only include terms that are assigned to something) $allGuestNumbers = get_terms(array(‘taxonomy’ => ‘property-guests’)); // Create a variable … Read more

Set both meta_query and tax_query using wp_query->set

Just use another set() method: if ($value[‘pRange’] && $value[‘tags’]) { $wp_query->set(‘tax_query’, array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘pa_branding’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), ) ); $wp_query->set(‘meta_query’, array( ‘relation’ => ‘AND’, … Read more

get_users with array as meta_value

First, can use meta_query, but, you should change your values to use the proper date format, e.g. 2020/01/02 for January 2nd, rather than a regional format. See https://en.wikipedia.org/wiki/ISO_8601 for more details. Second, your LIKE query is going to be very expensive, and achieving what you want while still using a LIKE query will be even … Read more