Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51596 closed enhancement (duplicate)

Posts embedded in search results are incomplete

Reported by: iandunn's profile 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.

Possibly related: #49538, #49985

Change History (2)

#1 @TimothyBlynJacobs
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Embeds only return fields that have the embed context. You can add embed to the context 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.

#2 @iandunn
4 years ago

Ah, that makes sense, thanks!

Note: See TracTickets for help on using tickets.