I found this question very interesting ,So here is what i have done to make this possible.
Fetch page template and add them as sub menu of Post type page.
function addTemplateAddNewSubMenu() {
global $submenu;
// here we are fetching all page template from current activated theme.
$templates = wp_get_theme()->get_page_templates( 'page' );
foreach ( $templates as $filename => $title ) {
if ( $filename != 'default' && $filename != '' ) {
// add page-template filename as query string to add new page link.
$url = 'post-new.php?post_type=page&template=' . $filename;
$submenu['edit.php?post_type=page'][] = array( 'Add new ' . $title , 'manage_options', $url );
}
}
}
add_action( 'admin_menu', 'addTemplateAddNewSubMenu' );
I have added page template as query string to
/wp-admin/post-new.php?post_type=page&template=template-contact.php
Making page template dropdown selected by jQuery and template Query string.
add_action( 'admin_head','selectPageTemplate' );
function selectPageTemplate() {
global $pagenow;
if ( $pagenow == 'post-new.php' ) {
if ( get_post_type() == 'page' && isset($_GET['template']) ) {
$template = $_GET['template']; ?>
<script>
jQuery(function($){
$('#page_template').val('<?php echo $template;?>');
});
</script>
<?php
}
}
}
