In wordpress we have an option to assign a post as a child to another post. In order to get the ancestors of a post wordpress have an inbuilt function i.e. get_post_ancestors( ).
This function will have one argument that can be either post id or post object and it returns the ancestor’s ids as an array.
$ancestors=get_post_ancestors($post_id);
No comments:
Post a Comment