How can I add a 'Page Template' column to the Dashboard, so that viewing 'All cpt_name' shows which template is used.
1 Answer
<?php
// add new column to the columns array
function wpse267793_columns($columns) {
// Column name
$columns['template'] = 'Template file';
return $columns;
}
function wpse267793_show_template_columns($name, $post_id) {
// get template file name from post meta
$template = get_post_meta($post_id, '_wp_page_template', true);
echo $template;
}
// change 'CPT' to the relevant custom post type
add_filter('manage_CPT_posts_columns', 'wpse267793_columns');
add_action('manage_CPT_posts_custom_column', 'wpse267793_show_template_columns', 10, 2);
-
@ Max Yudin ... Thanks. I delayed responding because adding this column also adds the template info to an additional column I'd added previously to show post ID, and I wanted to try to find a fix before posting here - but haven't yet been able to do so.– glvrMay 24, 2017 at 10:53
-
-
-
-
@ Max Yudin ... if you don't know what to search for, it's difficult to find answers. And, as always, I searched before posting here.– glvrMay 24, 2017 at 15:06