WordPress at a glance

get_page_templates() WP 1.0

Get the Page Templates available in this theme

Is the basis for: page_template_dropdown()

No Hooks.


Array. Key is the template name, value is the filename of the template


get_page_templates( $post, $post_type );
The post being edited, provided for context.
Default: null
Post type to get the templates for.
Default: 'page'


Since 1.5.0 Introduced.
Since 4.7.0 Added the $post_type parameter.

Code of get page templates: wp-admin/includes/theme.php WP 5.2.4

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

Related Functions

From category: Other Theme Functions

No comments
    Hello, !     Log In . Register