Title: Returning custom posts
Last modified: August 31, 2016

---

# Returning custom posts

 *  Resolved [vince_](https://wordpress.org/support/users/vince_/)
 * (@vince_)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/returning-custom-posts/)
 * I have created a custom type with `https://wordpress.org/plugins/custom-post-
   type-ui/`
 * I’ve made my own controller and it currently works with this function :
 *     ```
       public function get_posts_by_city() {
         global $json_api;
   
         // Make sure we have key/value query vars
         if (!$json_api->query->key || !$json_api->query->value) {
           $json_api->error("Include a 'key' and 'value' query var.");
         }
   
         $posts = $json_api->introspector->get_posts(array(
           $json_api->query->key => $json_api->query->value
         ));  
   
         $wp_custom_fields = get_post_custom("3");
   
         return array(
           'posts' => $posts
         );
       }
       ```
   
 * I call it successfully with this URL :
 * `…/get_posts_by_city/?key=cat&value=3
 * What should I do to return my custom posts only ?
 * Thanks
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [vince_](https://wordpress.org/support/users/vince_/)
 * (@vince_)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/returning-custom-posts/#post-7323307)
 *     ```
       $posts = $json_api->introspector->get_posts(array(
           $json_api->query->key => $json_api->query->value,
       	'post_type' => 'bars'
         ));
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Returning custom posts’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [controller](https://wordpress.org/support/topic-tag/controller/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 1 reply
 * 1 participant
 * Last reply from: [vince_](https://wordpress.org/support/users/vince_/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/returning-custom-posts/#post-7323307)
 * Status: resolved