Was working on a project this week and I needed to see the page templates used for the pages. A lot of pages. I would have to go to the edit screen for each page and then check the template used and make a note of it for future reference. So instead I just took a minute to write a bit of custom code to show me the template that’s used.
Result
Plugin
I also released it as a free plugin, so if you prefer that you can download it at wordpress.org/plugins/page-template-column. Otherwise, check the code below.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
add_filter( 'manage_pages_columns', 'codismo_table_columns', 10, 1 ); add_action( 'manage_pages_custom_column', 'codismo_table_column', 10, 2 ); function codismo_table_columns( $columns ) { $custom_columns = array( 'codismo_template' => 'Template' ); $columns = array_merge( $columns, $custom_columns ); return $columns; } function codismo_table_column( $column, $post_id ) { if ( $column == 'codismo_template' ) { echo basename( get_page_template() ); } } |
Very simple code but saves me a ton of time, hope it saves yours too.