Get recent wordpress posts in Laravel Get recent wordpress posts in Laravel wordpress wordpress

Get recent wordpress posts in Laravel


Recent WordPress was released with a huge thing called REST API – earlier it was possible only with external plugins. So now we can query WordPress database from external projects. Including Laravel.

set up a local WordPress website, and after installation you got that usual dashboard.

we can already make API calls after installation. No need to configure anything, we just launch the URL in the browser:

we’ve received a JSON with a list of posts – by default, WordPress creates one dummy post.Basically, URL structure for the API calls is simple:

/wp-json/wp/v2/[endpoint]?[parameters]

Yes, you’ve read it right, we can get posts, categories, tags and other things that are publicly available, so we don’t need any authentication here.

And we also can filter the data with GET parameters, like this:

/wp-json/wp/v2/posts?per_page=2&orderby=title

For more details open link:- Using WordPress REST API in Laravel


You can get the posts by calling an API endpoint:

yoursiteurl/wp-json/wp/v2/posts

It will return all the posts in a json format. You can also see the reference from here.