admin管理员组文章数量:1122832
I have this url mysite/wp-json/wp/v2/posts
. it gets me all the posts I want, but what I need is the Parent ID of the Post. Is there an endpoint for example mysite/wp-json/wp/v2/parent/{postID}
??
I have this url mysite.com/wp-json/wp/v2/posts
. it gets me all the posts I want, but what I need is the Parent ID of the Post. Is there an endpoint for example mysite.com/wp-json/wp/v2/parent/{postID}
??
- 1 Hey! As far as I know, posts can’t have parents, but pages can. So the page endpoint also provides you with the parent ID, but the post endpoint doesn’t. Does that help or am I misinterpreting your question? – FMJansen Commented Sep 5, 2020 at 19:58
- I think it helps, thank you! – evara killer Commented Sep 5, 2020 at 22:01
1 Answer
Reset to default 0As posts can’t have parents, there is no endpoint to get the parent ID of a post.
However, pages can have parents, so the page endpoint should return a parent ID, among other things. So, by getting mysite.com/wp-json/wp/v2/pages
, you should be able to get the parent
attribute, which is “The ID for the parent of the object.” If you want just the parent, you could use _filter
in your request.
本文标签: WordPress rest API get Posts parent by post ID
版权声明:本文标题:WordPress rest API get Posts parent by post ID 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736287892a1927979.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论