WP_Query with MetaQuery issue

You may want to try adding the ‘RELATION’ => parameter into your meta query array so that you can encompass all of your meta values. Something like this: $v_args = array( ‘post_type’ => ‘loads_available’, ‘s’ => “Post Name”, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘type_of_load’, ‘value’ => “Frozen”, ‘compare’ => ‘=’, ), … Read more

Create custom query for search?

Have you check your result-set, what result you are getting in $query obj. another thing, there is no need to use ‘relation’ => ‘OR’, in meta query array, have a try with this as well. And instead of ‘numberposts’ use ‘posts_per_page’ this will help. 🙂 or you can remove the meta_query and make your $arg … Read more

Filter posts/pages by user_role array

You’ve used LIKE comparison method, that means every similar expression will be matched, including exact string and similar string. If you want to match exact string, you should use = operator. Example: global $current_user; $user_roles = $current_user->roles; $user_role_query = array(); for ($i=0; $i < sizeof($user_roles); $i++) { $user_role_query[] = array( ‘key’=>’attribution_roles’, ‘value’ => $user_roles[$i], ‘compare’=>’=’ … Read more