WP_REST_Template_Revisions_Controller::get_parent( int $parent_post_id ): WP_Post|WP_Error

Gets the parent post, if the ID is valid.


Parameters

$parent_post_id int Required
Supplied ID.

Top ↑

Return

WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php. View all references

protected function get_parent( $parent_post_id ) {
	$template = get_block_template( $parent_post_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 );
}


Top ↑

Changelog

Changelog
Version Description
6.4.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.