Skip to content

Instantly share code, notes, and snippets.

@jakewhiteley
Last active August 29, 2015 14:09
Show Gist options
  • Save jakewhiteley/ed201aa6f2f98e19f583 to your computer and use it in GitHub Desktop.
Save jakewhiteley/ed201aa6f2f98e19f583 to your computer and use it in GitHub Desktop.
<?php
/**
* For each page each, loop through registered columns, and output value
* @param String - current column name
* @param Int - current page ID
*/
function populate_column ( $column, $page_id )
{
switch ( $column ) {
// if the current column name is template
case 'template' :
$p = get_page_template_slug( $page_id ); // get current page template
echo ($p == '' ? 'Default Template' : $p); // write 'Default Template' if no custom template detected
break;
}
}
// hook our function nito Wordpress
add_action('manage_pages_custom_column', 'populate_column', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment