| | 390 | * Whether the post has parent. |
| | 391 | * |
| | 392 | * @since 4.3.0 |
| | 393 | * |
| | 394 | * @param int|WP_Post $id Optional. Post ID or post object. |
| | 395 | * @return bool |
| | 396 | */ |
| | 397 | function has_parent( $id = 0 ) { |
| | 398 | $post = get_post( $id ); |
| | 399 | return ( $post->post_parent > 0 ); |
| | 400 | } |
| | 401 | |
| | 402 | /** |
| | 403 | * Retrieve the parent post ID. |
| | 404 | * |
| | 405 | * @since 4.3.0 |
| | 406 | * |
| | 407 | * @param int|WP_Post $id Optional. Post ID or post object. |
| | 408 | * @return int |
| | 409 | */ |
| | 410 | function get_parent( $id = 0 ) { |
| | 411 | $post = get_post( $id ); |
| | 412 | if ( empty( $post ) || ( $post->post_parent <= 0 ) ) { |
| | 413 | return ''; |
| | 414 | } |
| | 415 | |
| | 416 | /** |
| | 417 | * Filter the retrieved post parent. |
| | 418 | * |
| | 419 | * @since 4.3.0 |
| | 420 | * |
| | 421 | * @param string $post_parent The post parent. |
| | 422 | */ |
| | 423 | return apply_filters( 'get_parent', $post->post_parent ); |
| | 424 | } |
| | 425 | |
| | 426 | /** |