wp_get_post_parent_id()
Returns the ID of the post's parent.
Хуков нет.
Возвращает
int|false
. Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.
Использование
wp_get_post_parent_id( $post );
- $post(int|WP_Post|null)
- Post ID or post object.
По умолчанию: global $post
Список изменений
С версии 3.1.0 | Введена. |
С версии 5.9.0 | The $post parameter was made optional. |
Код wp_get_post_parent_id() wp get post parent id WP 6.3.1
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; }