Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 34509

Custom Post Types extend WordPress to support additional content.

1 vote
1 answer
362 views

WP Rest API - How to get an empty response if query has no posts

I am using rest_{post_type}_query for some custom query params. It works fine, however, I would like to get an empty response or a "no posts found" message when the query doesn't have the posts ids to …
shubhra's user avatar
  • 148
0 votes
Accepted

WP Rest API - How to get an empty response if query has no posts

I found my answer in WP_REST_Posts_Controller class /* * If we intersected, but there are no post ids in common, * WP_Query won't return "no posts" for post__in = array() * so we have to fake it a bi …
shubhra's user avatar
  • 148