Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get most recent post using WP-API JS

I'd like to be able to return the most recent Wordpress post from my blog using the WP-API (Version 2).

I can't work out what to put after:

/wp-json/wp/v2/

Any help is much appreciated. - Thanks.

like image 981
Tristan Kirkpatrick Avatar asked Aug 06 '26 07:08

Tristan Kirkpatrick


2 Answers

Try this - /wp-json/wp/v2/posts?filter[posts_per_page]=1

like image 80
Lucy Brown Avatar answered Aug 07 '26 19:08

Lucy Brown


According to the docs you specify the number of records to return in one request with the parameter per_page so /wp/v2/posts?per_page=1 will return only the first post.

like image 36
Daniel Avatar answered Aug 07 '26 20:08

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!