The HTML attribute name
is what is sent to the server. There is some PHP code reading it and storing it with a specific key in the database.
The HTML name and the database key don’t have to be the same string. The PHP code can use a completely different name or split one value into multiple database values.
The template attribute handler does that: It takes the name page_template
from page attributes metabox and stores it as _wp_page_template
in the database. The leading underscore protects that field from showing up in the custom fields metabox.
See this part in wp_insert_post()
:
if ( !empty($page_template) && 'page' == $data['post_type'] ) {
$post->page_template = $page_template;
$page_templates = wp_get_theme()->get_page_templates();
if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) {
if ( $wp_error )
return new WP_Error('invalid_page_template', __('The page template is invalid.'));
else
return 0;
}
update_post_meta($post_ID, '_wp_page_template', $page_template);
}