get_post_parent()
最后更新于:2021-11-26 22:35:34
get_post_parent( int|GC_Post|null$post=null)Retrieves the parent post object for the given post.
参数
- $post
-
(int|GC_Post|null) (Optional) Post ID or GC_Post object. Default is global $post.
Default value: null
响应
(GC_Post|null) Parent post object, or null if there isn’t one.
源文件
文件: gc-includes/post-template.php
function get_post_parent( $post = null ) {
$gc_post = get_post( $post );
return ! empty( $gc_post->post_parent ) ? get_post( $gc_post->post_parent ) : null;
}