id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 49695,REST API check_template function can return false error,Kipperlenny,TimothyBlynJacobs,"wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php Line 1209 function check_template ---- This function does not check get_post for an empty post: {{{#!php get_page_templates( get_post( $request['id'] ), $this->post_type ); }}} On my Setup, this returned the WP_Error rest_invalid_param because get_post() returned an empty Post (with $post->ID == 0). I changed this to: {{{#!php ID == 0) { $post = null; } // If this is a create request, get_post() will return null and wp theme will fallback to the passed post type. $allowed_templates = wp_get_theme()->get_page_templates( $post, $this->post_type ); }}} This checks, if post is empty. This will save some API Requests from running in errors and does no harm. PS: No idea, why get_post() can return an empty WP_Post object. My API did not send an ID and was a POST Request. ",defect (bug),closed,normal,5.6,REST API,4.9,normal,fixed,2nd-opinion dev-feedback needs-patch needs-unit-tests,,rest-api