
WordPress钩子详解:如何使用动作、过滤器和自定义钩子
wp_get_post_parent_id ( $post = null )
wp_get_post_parent_id: 这个函数为一个给定的文章检索父文章的ID。它接受一个文章的ID作为参数。
返回该文章的父级ID。
function wp_get_post_parent_id( $post = null ) { $post = get_post( $post ); if ( ! $post || is_wp_error( $post ) ) { return false; } return (int) $post->post_parent; }