Warning: Array to string conversion in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 789
Warning: foreach() argument must be of type array|object, string given in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 794
Warning: Array to string conversion in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 789
WP_REST_Revisions_Controller::get_parent( int $parent_post_id )
Get the parent post, if the ID is valid.
Warning: Array to string conversion in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 789
Warning: foreach() argument must be of type array|object, string given in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 794
Warning: Array to string conversion in /var/www/public/docs.classicpress.net/public_html/wp-content/themes/cpnet-developer/inc/template-tags.php on line 789
Parameters
- $parent_post_id
-
(Required) Supplied ID.
Return
(WP_Post|WP_Error) Post object if ID is valid, WP_Error otherwise.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
protected function get_parent( $parent ) {
$error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) );
if ( (int) $parent <= 0 ) {
return $error;
}
$parent = get_post( (int) $parent );
if ( empty( $parent ) || empty( $parent->ID ) || $this->parent_post_type !== $parent->post_type ) {
return $error;
}
return $parent;
}
Changelog
| Version | Description |
|---|---|
| 4.7.2 | Introduced. |