The question says it all, I think. I’d like to create a new submenu page using edit.php which will only display pages which use a certain template file (or files).
Possible?
The question says it all, I think. I’d like to create a new submenu page using edit.php which will only display pages which use a certain template file (or files).
Possible?
Try this:
<?php
// add submenu page
add_action('admin_menu', 'add_template_submenu');
function add_template_submenu()
{
add_pages_page( 'My Template', 'My Template', 'edit_pages', 'edit.php?post_type=page&template=your-template-file.php');
}
// check for the template name passed in $_GET and add it to the query
add_filter('parse_query', 'filter_pages');
function filter_pages($query)
{
global $typenow, $pagenow;
if ($pagenow == 'edit.php' && $typenow == 'page' && $_GET['template'])
{
$query->query_vars['meta_key'] = '_wp_page_template';
$query->query_vars['meta_value'] = $_GET['template'];
}
return $query;
}