WP_Query orderby meta key/value suddely stopped working

Some things to check. Have permissions changed during your migration? Sometimes those things change unexpectedly. Use Chrome inspector to see if any Javascript is failing to load (look for the red x). Have you updated permalinks? Is your new dedicated environment able to support the requirements of everything you’re running? If your code hasn’t changed, … Read more

Creating Custom Query

Try following codes: $country_search_array = array(); while($row = mysql_fetch_array($regionresult)){ $country_search_array[] = $row[‘country’]; // Your country field name } $country_search = “‘”.implode(“‘,”, $country_search_array).”‘”; $args = array( ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘Country’, ‘value’ => $country_search, ‘compare’ => ‘IN’ ) ) ); $query = new WP_Query( $args );

Query author’s posts & posts that have author’s id as meta value

Instead of a new WP_Query, use the pre_get_posts filter add_filter(‘pre_get_posts’, ‘custom_query’); function custom_query($query) { if($query->is_main_query() && $query->is_author() && $_GET[‘eco’]==’somemetakey’) { $query->set(‘meta_query’, array( array( ‘key’ => ‘somemetakey’, ‘value’ => $query->get(‘author’) ) )); } }

loop through custom post-type with two meta_keys

You’ll need to use meta_query along with meta_(key|value|compare) to interact with two different keys and get the order you want. <?php $q = new WP_Query(array( ‘post_type’ => ‘my_project’, ‘nopaging’ => true, // same as posts_per_page => 1, ‘order’ => $order, ‘orderby’ => ‘is_featured_position’, // your position key here ‘meta_key’ => ‘is_featured_position’, // also here, see … Read more

Filtering problem

… I will need to be more specific, by adding a “%” after $author (James). The problem is that this will not work at all. Any idea why? The % is a wildcard with a MySQL LIKE query, which I suspect you know. With meta queries, WordPress will add one to the beginning and one … Read more