Get featured image and additional posts thumbnail Wordpress REST API
I want to use the REST API of wordpress to build a new version of a custom theme. I'm able to get the json response of a particular category, but I need to find a way to obtain also the featured image or the second post thumbnail registered using a plugin, so I can use them in the layout. Is this possible without using a plugin?
here is the code I'm using for testing:
script
(function($){
$(document).ready(function(){
$.getJSON('https://localhost/wordpress/wp-json/wp/v2/posts?category_name=portfolioper_page=50_embed', function(response){
console.log(response);
$.each(response, function(i){
console.log(response[i]._embedded['wp:featuredmedia'][0].source_url);
});
});
});
}(jQuery));
/script
the last part of the console log will not work but the [0].source_url
is the info I need for each JSON post provided.
Topic rest-api post-thumbnails Wordpress
Category Web