Created
February 6, 2013 15:48
-
-
Save grex22/4723427 to your computer and use it in GitHub Desktop.
WordPress code for displaying all unused page templates. Great for cleaning out a bloated site with lots of old page templates!
This file contains 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
$pages = get_posts('post_type=page&showposts=-1&post_status=any'); | |
$tarray = array(); | |
foreach($pages as $p){ | |
$tarray[] = get_post_meta($p->ID, '_wp_page_template', true); | |
} | |
$used = array_unique($tarray); | |
$all = array(); | |
include_once ABSPATH . 'wp-admin/includes/theme.php'; | |
$templates = get_page_templates(); | |
foreach ( $templates as $template_name => $template_filename ) { | |
$all[] = $template_filename; | |
} | |
$diff = array_diff($all,$used); | |
print_r($diff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment