WP_REST_Revisions_Controller::get_parent() – Get the parent post, if the ID is valid.
You appear to be a bot. Output may be restricted
Description
Get the parent post, if the ID is valid.
Usage
$WP_Post|WP_Error = WP_REST_Revisions_Controller::get_parent( $parent_post_id );
Parameters
- $parent_post_id
- ( int ) required – Supplied ID.
Returns
WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
Source
File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Lines:
1 to 22 of 22
protected function get_parent( $parent_post_id ) { $error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); if ( (int) $parent_post_id <= 0 ) { return $error; } $parent_post = get_post( (int) $parent_post_id ); if ( empty( $parent_post ) || empty( $parent_post->ID ) || $this->parent_post_type !== $parent_post->post_type ) { return $error; } return $parent_post; }