Gets the page templates available in this theme.
Parameters
$post
WP_Post|nulloptional- The post being edited, provided for context.
Default:
null
$post_type
stringoptional- Post type to get the templates for. Default
'page'
.Default:
'page'
Source
function get_page_templates( $post = null, $post_type = 'page' ) {
return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}
Output a list of available templates
The following code snippet loops through the available page templates and outputs their template names and the filenames.
Returns: