posts – Getting featured image with PHP and not javascript from wordpress api _embed

Question

Not having access to the functions file, I can’t add the function to add the featured image to the API so I need to use wp-json/wp/v2/posts?_embed.

With javascript I believe it is ._embedded['wp:featuredmedia']['0'].source_url so I tried with php after using wp_remote_get, $post->_embedded['wp:featuredmedia'][0]->source_url but the error I am getting is :

Cannot use object of type stdClass as array

0
user8463989 2 months 2022-06-02T08:03:42-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse