admin管理员组文章数量:1296401
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.
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.
Share Improve this question asked Nov 28, 2015 at 18:25 Tristan KirkpatrickTristan Kirkpatrick 1552 silver badges11 bronze badges4 Answers
Reset to default 4Try this - /wp-json/wp/v2/posts?filter[posts_per_page]=1
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.
public Page: string = "posts?per_page=num&offset=num&_embed&category_id=num';";
'categories=num'be used alternatively.
Latest Posts with Restful API
This very simple but useful plugin can help with rewrite ajax with cache ability:
Installation (step by step):
In your WordPress website admin panel
- Go to Plugins.
- Click on Add new.
- Search for "restful api".
- install "Latest Posts with Restful API" and Activate it.
- At the Settings -> Permalink JUST CLICK SAVE to update site permalink address.
You can :
- Show latest posts + category name and post featured Image
(site_URL)/api/latestposts/(Number of POSTs - like 30)
- Get one post data + category name and post featured Image
(site_URL)/api/getpost/(post ID)
- Get one VIP category post called "mobile_app_more"
(site_URL)/api/moretab/1
Download Latest Posts with Restful API
Plugin GitHub Page
Hope this help : ) especially when "wp-json" is disable by firewall plugin!
本文标签: javascriptGet most recent post using WPAPI JSStack Overflow
版权声明:本文标题:javascript - Get most recent post using WP-API JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741637314a2389713.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论