wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_post_parent › WordPress Function

Since5.7.0
已弃用n/a
get_post_parent ( $post = null )
参数:
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required: No
    默认: null
返回:
  • (WP_Post|null) Parent post object, or null if there isn't one.
定义在:
文档:

Retrieves the parent post object for the given post.



源码

function get_post_parent( $post = null ) {
	$wp_post = get_post( $post );
	return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null;
}