public handle_template ( string $template, integer $post_id ) | ||
$template | string | Page template filename. |
$post_id | integer | Post ID. |
public function handle_template($template, $post_id)
{
if (in_array($template, array_keys(wp_get_theme()->get_page_templates(get_post($post_id))), true)) {
update_post_meta($post_id, '_wp_page_template', $template);
} else {
update_post_meta($post_id, '_wp_page_template', '');
}
}