WP_REST_Posts_Controller::handle_template() – Sets the template for a post.
You appear to be a bot. Output may be restricted
Description
Sets the template for a post.
Usage
WP_REST_Posts_Controller::handle_template( $template, $post_id, $validate );
Parameters
- $template
- ( string ) required – Page template filename.
- $post_id
- ( int ) required – Post ID.
- $validate
- ( bool ) optional – Whether to validate that the template selected is valid.
Returns
void
Source
File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Lines:
1 to 8 of 8
public function handle_template( $template, $post_id, $validate = false ) { if ( $validate && ! array_key_exists( $template, wp_get_theme()->get_page_templates( WP_REST_Posts_Controller::get_post( $post_id ) ) ) ) { $template = ''; } update_post_meta( $post_id, '_wp_page_template', $template ); }