WordPress at a glance

get_page_templates() WP 1.0

Get the Page Templates available in this theme

  • Since 4.7.0 Added the $post_type parameter.
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'

Code of get_page_templates: wp-admin/includes/theme.php VER 5.0

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