Hi Mikeshinobi,
I have tried this code & it works for me, check below
function add_custom_template_filter() {
global $typenow;
if( $typenow == 'page' ){
$templates = wp_get_theme()->get_page_templates();
echo '<select name="custom_template_filter">';
echo "<option value=''>Show All Templates</option>";
foreach ( $templates as $template_name => $template_filename ) {
if(isset($_GET['custom_template_filter']) && ($_GET['custom_template_filter'] == $template_name)){
$selected = "selected";
}else{
$selected = '';
}
echo '<option value="'.$template_name.'" '.$selected.'>' . $template_filename .'</option>';
echo $template_filename.'<br>';
}
echo '</select>';
}
}
add_action( 'restrict_manage_posts', 'add_custom_template_filter' );
add_filter( 'parse_query', 'sort_page_by_template' );
function sort_page_by_template($query) {
global $pagenow;
if(is_admin() && $pagenow=='edit.php' && isset($_GET['post_type']) && isset($_GET['post_type'])=='page' && $_GET['custom_template_filter'] != ''){
$query->query_vars['meta_key'] = '_wp_page_template';
$query->query_vars['meta_value'] = $_GET['custom_template_filter'];
}
}
This will add a drop down in page listing backend and then you can filter based on template selected, Cheers !