get_page_templates( WP_Post|null $post = null, string $post_type = 'page' )

Gets the page templates available in this theme.


Parameters

$post

(Optional) The post being edited, provided for context.

Default value: null

$post_type

(Optional) Post type to get the templates for. Default 'page'.

Default value: 'page'


Return

(string[]) Array of template file names keyed by the template header name.


Source

File: wp-admin/includes/theme.php

function get_page_templates( $post = null, $post_type = 'page' ) {
	return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}


Changelog

Changelog
Version Description
4.7.0 Added the $post_type parameter.
1.5.0 Introduced.