WordPress.org

Make WordPress Core

Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#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.

Possibly related: #49538, #49985

Change History (2)

#1 @TimothyBlynJacobs
11 months 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
11 months ago

Ah, that makes sense, thanks!

Note: See TracTickets for help on using tickets.