Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#59552 new defect (bug)

Rest api not returns embedded data,if i use at least one field.

Reported by: sashakozlovskiy's profile sashakozlovskiy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Embeds Keywords:
Focuses: rest-api Cc:

Description

Hello. after updating of wordpress,rest api not returns embedded data,if we use at least one field,so we downgraded wordpress,but created test subdomain,which contains latest wordpress. Please compare requests:
https://опиши-мне.рф/wp-json/wp/v2/posts/5926/?_fields=content&_embed=author,wp:term
and
https://2019.опиши-мне.рф/wp-json/wp/v2/posts/5926/?_fields=content&_embed=author,wp:term

in second case it returns only content field,but in first - content field and embedded data. Please help to us fix this issue. Thank you very much.

Change History (6)

#1 @swissspidy
5 months ago

There was a breaking change in a recent WordPress release where now you need to include the „_embedded“ field (or whatever the key is called) as well if you do something like this.

#2 @sashakozlovskiy
5 months ago

Ok,but whether you updated it in rest api book and how i can for now get only field content and embedded author and wp:term

#3 @spacedmonkey
5 months ago

@sashakozlovskiy In your request, you are not requesting the _embedded fields. It works if you add that

https://2019.xn----jtbhavgci6f.xn--p1ai/wp-json/wp/v2/posts/5926/?_fields=content,_embedded&_embed=author,wp:term

This changed in core back in 2022, see the original make blog post.

#4 @sashakozlovskiy
5 months ago

Thank you very much. Now i understand,what for now i should  add field with name _embedded together with content. Because i not understood before,what means _embedded field. Let God bless to you. Please,explain to me,whether it possible exclude embedded parts,for example from links exclude collection,etc.

#5 @spacedmonkey
5 months ago

Please,explain to me,whether it possible exclude embedded parts,for example from links exclude collection,etc.

@sashakozlovskiy It is possible. You can do this ?_fields=_links.self. But if you are embedding then links are always returned.

#6 @sashakozlovskiy
5 months ago

So,in embedded mode i cant exclude self from links?

Note: See TracTickets for help on using tickets.