0

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} ??

2
  • 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! Commented Sep 5, 2020 at 22:01

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.