Title: WP_Query() posts
Last modified: February 2, 2024

---

# WP_Query() posts

 *  Resolved [cupcakes99](https://wordpress.org/support/users/cupcakes99/)
 * (@cupcakes99)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wp_query-posts/)
 * Hi. How can I prevent restricted posts from appearing in custom WP_Query() for
   those that don’t have access? Using `groups_filter_the_posts` ?
   If so, please
   provide an example because I am receiving errors so I must be doing something
   wrong. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wp_query-posts/#post-17393920)
 * Hi,
 * In your WP_Query make sure that `suppress_filters` is `false` (which it is by
   default so if you don’t pass that parameter it would be ok, using `true` however
   would prevent Groups from applying the restrictions).
 * In most cases, you probably wouldn’t need to use `groups_filter_the_posts` because
   it hooks into the `posts_where` filter to apply restrictions. However, if you
   still need it, you can enable it using the predefined `__return_true()` WordPress
   function with the filter:
 *     ```wp-block-code
       add_filter( 'groups_filter_the_posts', '__return_true' );
       ```
   
 * But you should make sure that this only applies when it is really needed, to 
   avoid any processing overhead it would create otherwise.
 * Cheers
 *  Thread Starter [cupcakes99](https://wordpress.org/support/users/cupcakes99/)
 * (@cupcakes99)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wp_query-posts/#post-17393949)
 * Thank you for such a speedy reply, and also a great plugin!
 * It turns out that I don’t actually need the filter… I had just accidentally assigned
   users to the wrong group which is why they could still see the posts 🙈🤣
 * Good to know though, thanks!
 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/wp_query-posts/#post-17418244)
 * Thank you very much for the follow-up, yes that explains it 😛
 * Great that it’s working for you and if you have any suggestions or questions,
   just let us know. I’ll mark this one as resolved.
 * BTW if you can spare a minute, feedback on the plugin is always welcome [https://wordpress.org/support/plugin/groups/reviews/#new-post](https://wordpress.org/support/plugin/groups/reviews/#new-post)
 * Many thanks for using it!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP_Query() posts’ 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/)

## Tags

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [group](https://wordpress.org/support/topic-tag/group/)
 * [restrict](https://wordpress.org/support/topic-tag/restrict/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kento](https://wordpress.org/support/users/proaktion/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/wp_query-posts/#post-17418244)
 * Status: resolved