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.

Return

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

Usage

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

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

<?php
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