Title: query_posts() Cannot find posts created by plugin.
Last modified: September 16, 2020

---

# query_posts() Cannot find posts created by plugin.

 *  [cchzhu](https://wordpress.org/support/users/cchzhu/)
 * (@cchzhu)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/query_posts-cannot-find-posts-created-by-plugin/)
 * Hi,
 * I am new to wordpress. I want to fetch the posts created by the plugin from php.
   I tried to use `query_posts()`, but it only returns the post created by wordpress
   admin not the third party plugin.
 * The URL for the post I want to find from php:
    `https://smap.cas.mcmaster.ca/
   wp-admin/post.php?post=1035&action=edit` The URL for the post that can be returned
   by`query_posts()`: `https://smap.cas.mcmaster.ca/wp-admin/post.php?post=1005&
   action=edit`
 * The only difference is the post id. If they are save in the same place, why the
   query_posts() cannot return the first one?
 * Thanks a lot!
    -  This topic was modified 5 years, 8 months ago by [cchzhu](https://wordpress.org/support/users/cchzhu/).

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

 *  [Md. Asraful Islam](https://wordpress.org/support/users/asraf123/)
 * (@asraf123)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/query_posts-cannot-find-posts-created-by-plugin/#post-13418127)
 * Hi [@cchzhu](https://wordpress.org/support/users/cchzhu/),
 * You should pass accurate parameter for custom code.
    Such as: query_posts(‘post_type
   =product’);
 * Please replace your post_type: **product** to ‘**your post type**‘
 * I hope it will work for you.
 * Thanks
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/query_posts-cannot-find-posts-created-by-plugin/#post-13420427)
 * FYI – query_posts() is inefficient because it discards the original main query
   which has already been done and starts a new query. You’re better off using the“
   pre_get_posts” action to set the main query’s query vars as you need instead 
   of using query_posts().
 * To get custom posts queried through “pre_get_posts”, if the passed query object
   is collected as `$query`, you’d do
    `$query->set('post_type', 'product'); // 
   or whatever your post type really is` from within the action callback.

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

The topic ‘query_posts() Cannot find posts created by plugin.’ is closed to new 
replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/query_posts-cannot-find-posts-created-by-plugin/#post-13420427)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
