How to easily get post ancestors

When using WordPress as a CMS or building a breadcrumb, you often need to get the post ancestors. Today let’s have a look at how you can easily get post ancestors of a specific post.

In order to get the post ancestors (also called parents) simply use the get_post_ancestors() function. This function takes a single argument which can be either the post ID or post object, and return the ancestors IDs as an array.$ancestors

View the Original article

0 comments:

Post a Comment