Title: error with  query
Last modified: September 1, 2016

---

# error with query

 *  [aprods](https://wordpress.org/support/users/aprods/)
 * (@aprods)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/error-with-query/)
 * Hi,
    I tried to gets custom post for filtering portfolio I use `$loop = new WP_Query(
   array('post_type' => 'portfolio', 'posts_per_page' => -1));`
 * That return
    `[request] => SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.
   post_type = 'portfolio' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status
   = 'private') ORDER BY wp_posts.post_date DESC`
 * And if I’m logged as admin, I can see the “confidential” item
 * But if I’m logged as subscriber in the group confidential the query is now:
    `[
   request] => SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type 
   = 'portfolio' AND (wp_posts.post_status = 'publish' OR wp_posts.post_author =
   16 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC`
 * And I don’t get the confidential items even the group as access to them
    The 
   problem is the “AND” in the query instead of “OR” wp_posts.post_status = ‘private’.
 * Any idea hoe to display the items to the group?
 * [https://wordpress.org/plugins/user-access-manager/](https://wordpress.org/plugins/user-access-manager/)

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

 *  [nbspjr](https://wordpress.org/support/users/nbspjr/)
 * (@nbspjr)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/error-with-query/#post-7568477)
 * Hey aprods,
 * I wonder if your confidential posts have “Private” status. By default, private
   posts are not accessible by Subscribers, no matter of group access.
 * Try one of the following:
    - Remove “private” flag
    - Specify ‘publish’ and ‘private’ post statuses in your custom query
    - Grant Subscribers access to Private posts, using a plugin like User Role Editor(
      I doubt it’s a good idea though)
 *  Thread Starter [aprods](https://wordpress.org/support/users/aprods/)
 * (@aprods)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/error-with-query/#post-7568478)
 * You’re right!
    The post was “private” and it was the issue
 * Thanks!

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

The topic ‘error with query’ is closed to new replies.

 * ![](https://ps.w.org/user-access-manager/assets/icon.svg?rev=1563783)
 * [User Access Manager](https://wordpress.org/plugins/user-access-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-access-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-access-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/user-access-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-access-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-access-manager/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [aprods](https://wordpress.org/support/users/aprods/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/error-with-query/#post-7568478)
 * Status: not resolved