A_Z_Listing::find_post_parent( WP_Post|int $page )

Find a post’s parent post. Will return the original post if the post-type is not hierarchical or the post does not have a parent.




(WP_Post|int) (Required) The post whose parent we want to find.


(WP_Post|bool) The parent post or the original post if no parents were found. Will be false if the function is called with incorrect arguments.


File: classes/class-a-z-listing.php

	public static function find_post_parent( $page ) {
		if ( ! $page ) {
			return false;
		if ( ! $page instanceof WP_Post ) {
			$page = get_post( $page );
		if ( ! $page->post_parent ) {
			return $page;
		return self::find_post_parent( $page->post_parent );


Version Description
1.4.0 Introduced.

More Information

You are currently logged out. To view tickets you must first login.

I have read and understood the Terms of Service

User Contributed Notes

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.