$result =
set_post_thumbnail( $post_id,
$featured_media );
if ( $result ) { return true;
} else { return new WP_Error( 'rest_invalid_featured_media',
__( 'Invalid featured media ID.'
),
array
( 'status' => 400
) );
} } else { return delete_post_thumbnail( $post_id );
} } /**
* Checks whether the template is valid for the given post.
*
* @since 4.9.0
*
* @param string $template Page template filename.
* @param WP_REST_Request $request Request.
* @return bool|WP_Error True if template is still valid or if the same as existing value, or false if template not supported.
*/