简体   繁体   中英

How to use embed query with wordpress rest api?

I use the _embed query with wordpress rest api and it works like this:

sitename/wp-json/wp/v2/posts?_embed

And I get the expected results. But when I use it with search method it doesn't return me the _embedded version of posts:

sitename/wp-json/wp/v2/search?_embed

How can I use the search rest api with embed?

I succeeded by ignoring the '/search' service and adding a 'search' url parameter to the '/posts' service

So it would look like this

sitename/wp-json/wp/v2/posts?_embed&search=searchTerm

You can add 'search' parameter to the '/posts' like this:

wp-json/wp/v2/posts?_embed&search=searchTerm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM