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}
??
-
1Hey! 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?– FMJansenCommented Sep 5, 2020 at 19:58
-
I think it helps, thank you!– evara killerCommented Sep 5, 2020 at 22:01
Add a comment
|
1 Answer
As 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.