Title: Disable it during REST request
Last modified: February 23, 2017

---

# Disable it during REST request

 *  Resolved [enricodeleo](https://wordpress.org/support/users/enricodeleo/)
 * (@enricodeleo)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/disable-it-during-rest-request/)
 * This is actually a solution more than a question. Since I couldn’t find a repo
   to contribute to.
 * **Problem**
    The plugin causes unwanted behaviours with wp rest api (built in
   in wp 4.7).
 * When the plugin is active, any attempt to search trough custom post types (eg/
   wp-json/wp/v2/posts?search=dante&post_type=book) fails returning any post type
   registered for rest.
 * **Solution**
    In order to keep the (very useful, so congrats!) features of this
   plugin within the frontend, you need to disable it just for rest requests. The
   following snippet just do this.
 *     ```
       /*
        *  Disable WP Extended Search during rest requests
        */
       function ed_rest_disable_wpes() {
         if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
           add_filter('wpes_enabled', '__return_false', 1, 1);
         }
       }
       add_action( 'rest_pre_serve_request', 'ed_rest_disable_wpes', 10, 0);
       ```
   

The topic ‘Disable it during REST request’ is closed to new replies.

 * ![](https://ps.w.org/wp-extended-search/assets/icon-256x256.png?rev=2436853)
 * [WP Extended Search](https://wordpress.org/plugins/wp-extended-search/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-extended-search/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-extended-search/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-extended-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-extended-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-extended-search/reviews/)

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [enricodeleo](https://wordpress.org/support/users/enricodeleo/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/disable-it-during-rest-request/)
 * Status: resolved