Is there a way to do nested embeds in the REST API?

Question

I’m trying to make a search widget, but search results have the corresponding post attached as a link, so to get the post in the result I have to do /wp-json/wp/v2/search?_embed=self.

This works to embed the post, but then if I want to embed the post terms I seem to be out of luck.

So far I’ve tried:

/wp-json/wp/v2/search?_embed=self,wp:terms

/wp-json/wp/v2/search?_embed=self,self.wp:terms

/wp-json/wp/v2/search?_embed=self,self[wp:terms]

/wp-json/wp/v2/search?_embed=true

None result in any of the nested links being embedded like I was hoping. Is there a way to do this at all? If not my next thought is to just use register_rest_field to put the relevant information onto the post myself.

0
Erin Dachtler 1 week 2022-08-03T14:52:37-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse