• Resolved jorensm

    (@jorensm)


    I have some query alterations made using the pre_get_posts hook, but I don’t want it to affect REST API calls. How can I do this?

Viewing 1 replies (of 1 total)
  • Thread Starter jorensm

    (@jorensm)

    I found out that you can check if it’s a REST query using the REST_REQUEST constant, like so:

    if( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
        // ...do RESTy things
    }
Viewing 1 replies (of 1 total)
  • The topic ‘How to prevent pre_get_posts from altering REST API queries’ is closed to new replies.