Custom Column with Currently Active Page Template

Snippets by IsItWP

Do you want to add a column to your admin pages showing the active WordPress page template? While you need to display additional information in your WordPress dashboard, we have created a quick code snippet that you can use to add a custom column with currently active page template.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

add_filter( 'manage_pages_columns', 'page_column_views' );
add_action( 'manage_pages_custom_column', 'page_custom_column_views', 5, 2 );
function page_column_views( $defaults )
   $defaults['page-layout'] = __('Template');
   return $defaults;
function page_custom_column_views( $column_name, $id )
   if ( $column_name === 'page-layout' ) {
       $set_template = get_post_meta( get_the_ID(), '_wp_page_template', true );
       if ( $set_template == 'default' ) {
           echo 'Default';
       $templates = get_page_templates();
       ksort( $templates );
       foreach ( array_keys( $templates ) as $template ) :
           if ( $set_template == $templates[$template] ) echo $template;

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 62 best free WordPress blog themes and 15 best content marketing tools and plugins for WordPress.

Comments   Leave a Reply

  1. Very nice 🙂 Thanks for sharing!

  2. Excellent code! Exactly what I wanted to do and done with a simple copy and paste.

    1. Shahzad Saeed March 1, 2019 at 6:27 am

      Glad it helped, Scott!

  3. Mike Eastwood July 4, 2017 at 1:17 am

    Thank you!

  4. This works great, but I am really struggling with sorting the column. I managed to make the column sortable. eg. I can click on the column title, and it definitely does something, but I think it is just reversing the natural order upside down :(, and what I need is to sort alphabetically by the template name.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!