Title: Identifying a JSON REST API request
Last modified: August 21, 2016

---

# Identifying a JSON REST API request

 *  [devinfd](https://wordpress.org/support/users/devinfd/)
 * (@devinfd)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/identifying-a-json-rest-api-request/)
 * I am using the filter pre_get_posts to include a custom post type with wordpress
   loop. However, using the JSON REST API the my_get_posts function fails because
   of the IF is_home()… test.
 * So, is there variable, definition or function set by the JSON REST API plugin
   that I can add to the if statement so that it will pass?
 *     ```
       add_filter( 'pre_get_posts', 'my_get_posts' );
       function my_get_posts( $query )
       {
           if ( ( is_home() && $query->is_main_query() ) || is_feed() )
               $query->set( 'post_type', array( 'post', 'update-history' ) );
   
           return $query;
       }
       ```
   
 * [http://wordpress.org/plugins/json-rest-api/](http://wordpress.org/plugins/json-rest-api/)

The topic ‘Identifying a JSON REST API request’ is closed to new replies.

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

 * 0 replies
 * 1 participant
 * Last reply from: [devinfd](https://wordpress.org/support/users/devinfd/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/identifying-a-json-rest-api-request/)
 * Status: not resolved