Gets the parent post, if the template ID is valid.
$parent_template_idstringrequired
protected function get_parent( $parent_template_id ) {
$template = get_block_template( $parent_template_id, $this->parent_post_type );
if ( ! $template ) {
return new WP_Error(
'rest_post_invalid_parent',
__( 'Invalid template parent ID.' ),
array( 'status' => 404 )
);
}
return get_post( $template->wp_id );
}
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/get_parent