Created
September 6, 2016 11:44
-
-
Save JeppeSigaard/dca43ffdc4babaeee31b650c3e008d50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* --------------------------------------- */ | |
// Show page templates as states in page list | |
add_filter( 'display_post_states', 'prfx_template_state', 10, 2 ); | |
function prfx_template_state($post_states, $post){ | |
// Fetch array of templates, returning Display name => slug, which is odd, but useful. | |
$templates = get_page_templates(); | |
// Let's only run on pages for now | |
if('page' === get_post_type($post->ID)){ | |
// Loop through and apply | |
foreach($templates as $name => $slug){ | |
if($slug === get_page_template_slug($post->ID)){ | |
$post_states[] = $name; | |
} | |
} | |
} | |
// Return the new list of states, ez! | |
return $post_states; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment