Last active
January 10, 2017 20:26
-
-
Save soderlind/107c5c382ecbd420599fe27052e769c0 to your computer and use it in GitHub Desktop.
Get WordPress post template data
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 | |
$current_theme = wp_get_theme(); // get WP_Theme object | |
if ( count( $post_templates = $current_theme->get_post_templates() ) ) { // https://developer.wordpress.org/reference/classes/wp_theme/get_post_templates/ | |
printf( '<pre>%s</pre>', print_r( $post_templates, true ) ); | |
} | |
/* | |
Prints: | |
Array | |
( | |
[game] => Array // Template Post Type | |
( | |
[template-game-review.php] => Game Review // file name => Template Name | |
) | |
) | |
*/ |
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 | |
/* | |
Template Name: Game Review | |
Template Post Type: game | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment