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


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

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

Leave an answer