Title: Custom Post Type not recognized in  &quot;have_posts() function&quot;
Last modified: August 30, 2016

---

# Custom Post Type not recognized in "have_posts() function"

 *  [kane07](https://wordpress.org/support/users/kane07/)
 * (@kane07)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-not-recognized-in-have_posts-function/)
 * Hi,
 * I have installed the plugin in my site and i’ve seen a problem with the custom
   post type. Explain more…
    In the file taxonomy-(custom-taxonomy-).php i have 
   a loop for the all object of custom-type… if the result are found in DB (without
   Elasticsearch) the loop found all the result, having a normal behavior. But if
   take the result from Elasticsearch in the $post variable not exist anyone object
   of the custom-type but all object are the default (post) type. It is as wordpress
   not recorgnize the custom if the result come from Elasticsearch plugin. For bypass
   this problem have add the next snippet before the loop
 * $args = array(‘post_type’ => “my-custom-post-type”);
    query_posts($args);
 * //loop
    if ( have_posts() ) : … …
 * On this mode the loop return again the post for my scope.
    This is a workaround.
   For optimal solution what’s the your’s advice
 * [https://wordpress.org/plugins/elasticsearch-indexer/](https://wordpress.org/plugins/elasticsearch-indexer/)

The topic ‘Custom Post Type not recognized in "have_posts() function"’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/elasticsearch-indexer_acd3f1.svg)
 * [Elasticsearch Indexer](https://wordpress.org/plugins/elasticsearch-indexer/)
 * [Support Threads](https://wordpress.org/support/plugin/elasticsearch-indexer/)
 * [Active Topics](https://wordpress.org/support/plugin/elasticsearch-indexer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elasticsearch-indexer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elasticsearch-indexer/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [kane07](https://wordpress.org/support/users/kane07/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-not-recognized-in-have_posts-function/)
 * Status: not resolved