Can I force WP_Query to return no results?

I’m working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The WP_Query technically will find results in the database, but I’d like to override that somehow to force it to return no results to trigger the if( $example->have_posts() ) to fail.

Is there some sort of parameter I can pass to WP_Query like 'force_no_results' => true that will force it to return no results?

3

Try

'post__in' => array(0)

Simple and to the point.

Update:

'post__in' => empty( $include ) ? [ 0 ] : $include,

Leave a Comment