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 );

WordPress Query Returning Every Post

Thanks for all of the help! It tured out to be a combination of issues: Instead of imploding the $country_search_array, it needs to be added as is to the query. Since it’s an array, we can’t use the ‘=’ for the compare value. It needs to be ‘IN’ I couldn’t have figured it out without … Read more

wp_pagenavi on WP_Query using customfields

Try this one you need to add ‘paged’ => get_query_var(‘page’) so your code in $my_query should be like this $my_query = new WP_Query(array( ‘post_type’=>’post’, ‘posts_per_page’=>’1’, ‘paged’ => get_query_var(‘paged’) )); You just need to pass along the ‘paged’ query var from the main query: You can see also Codex page on query_posts()