搜索端点中的 WP REST API (wp json) 不返回完整数据

saj*_*asi 2 api wordpress json

在 WP REST API (wp json) 中的搜索端点:

\n\n
https://www.example.com/wp-json/wp/v2/search?search=searchPhrase&_embed\n
Run Code Online (Sandbox Code Playgroud)\n\n

返回的数据是这样的:

\n\n
0   \nid  5533\ntitle   "example"\nurl "https://www.example.co\xe2\x80\xa6"\ntype    "post"\nsubtype "post"\n_links  \nself    \n0   \nembeddable  true\nhref    "https://www.example.com/wp-json/wp/v2/posts/5533"\nabout   \n0   \nhref    "https://www.example.com/wp-json/wp/v2/types/post"\ncollection  \n0   \nhref    "https://www.example.com/wp-json/wp/v2/search"\n
Run Code Online (Sandbox Code Playgroud)\n\n

并且它返回的数据并不完整,就像/posts包含更多字段的端点一样content excerpt,...

\n\n

如何完成/search端点的输出数据?

\n\n

感谢您的时间。

\n

saj*_*asi 6

我找到了我们应该使用此端点的解决方案,该端点返回帖子的完整数据。

https://www.example.com/wp-json/wp/v2/posts?search=searchphrase&_embed
Run Code Online (Sandbox Code Playgroud)