WordPress rest API get Posts parent by post ID

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

Topic rest-api posts Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.