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.


Description


Parameters

$page

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


Return

(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.


Source

File: partials/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 );
	}

Changelog

Changelog
Version Description
1.4.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.

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