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

How to add parameters for custom post type

You want posts_per_page but you would have to create 2 queries to pull in 4 of each tag as the default code will pull in posts from either of the tags, not an equal amount between them. $args = array( ‘post_type’ => ‘customer-stories’, ‘tag’ => ‘microsoft’, ‘posts_per_page’ = ‘4’ ); $args2 = array( ‘post_type’ => … Read more