#51596 closed enhancement (duplicate)
Posts embedded in search results are incomplete
Reported by: | iandunn | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description
r46434 (#47684) made it possible to embed a post within a search results response (e.g., /wp-json/wp/v2/search?search=hello&_embed=self
). The object that gets embedded is incomplete, though. For instance, it has slug
and excerpt
, but not content
, status
, meta
, etc.
I'd like to be able to make a single request to the search endpoint, and obtain everything I need to know about the results, including its embedded terms, author, etc. Currently it seems like I need to make one request to get the IDs, and then another request to get the full info for all those posts.
A workaround would be register_rest_field( 'search-result', ...
, but modifying the Core endpoint feels hacky.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Embeds only return fields that have the
embed
context. You can addembed
to thecontext
specified in the schema using the"rest_{$this->post_type}_item_schema"
filter.I think we should handle this in #49538 and expand that to allow including fields that were omitted.