Page Template Column for Pages
Shows which page template each page uses, right in the Pages list.
Opens WPIDE on
Code
add_filter( 'manage_page_posts_columns', function ( $columns ) {
$columns['wpide_template'] = 'Template';
return $columns;
} );
add_action( 'manage_page_posts_custom_column', function ( $column, $post_id ) {
if ( 'wpide_template' !== $column ) {
return;
}
$slug = get_page_template_slug( $post_id );
if ( ! $slug ) {
echo '<span aria-hidden="true">—</span> Default';
return;
}
$templates = wp_get_theme()->get_page_templates( null, 'page' );
echo esc_html( isset( $templates[ $slug ] ) ? $templates[ $slug ] : $slug );
}, 10, 2 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.