Last active
February 5, 2016 10:20
-
-
Save keesiemeijer/1770ed2dde9041093940 to your computer and use it in GitHub Desktop.
get all 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
<?php | |
$post_templates = array(); | |
$theme = wp_get_theme(); | |
$files = (array) $theme->get_files( 'php', 1 ); | |
foreach ( $files as $file => $full_path ) { | |
$headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); | |
if ( empty( $headers['Template Name'] ) ) { | |
continue; | |
} | |
$post_templates[ $file ] = $headers['Template Name']; | |
} | |
echo '<pre>'; | |
print_r( $post_templates ); | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment