Title: Query Posts by Viewable Groups
Last modified: August 4, 2021

---

# Query Posts by Viewable Groups

 *  Resolved [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/query-posts-by-viewable-groups/)
 * I have a custom post type and a custom WP_Query. Is there a way to hide posts/
   not query posts in which the current user with their groups do not have access
   to view?
 * For example, Post A is only viewable by Group A. The current user is in Group
   B.
 * When I query posts, I don’t want to query Post A since the current user, in Group
   B, cannot view that post.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/query-posts-by-viewable-groups/#post-14735444)
 * Looks like it can be achieve with a meta_query
 *     ```
       'meta_query' => array( array(
           'key' => 'groups-read',
           'value' => $user_group_ids,
           'compare' => 'IN',
       ) )
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Query Posts by Viewable Groups’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/query-posts-by-viewable-groups/#post-14735444)
 * Status: resolved