get_page_templates

The timeline below displays how wordpress function get_page_templates has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.4

/**
 * Gets the page templates available in this theme.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `$post_type` parameter.
 *
 * @param WP_Post|null $post      Optional. The post being edited, provided for context.
 * @param string       $post_type Optional. Post type to get the templates for. Default 'page'.
 * @return string[] Array of template file names keyed by the template header name.
 */
function get_page_templates($post = null, $post_type = 'page')
{
    return array_flip(wp_get_theme()->get_page_templates($post, $post_type));
}

WordPress Version: 4.7

/**
 * Get the Page Templates available in this theme
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `$post_type` parameter.
 *
 * @param WP_Post|null $post      Optional. The post being edited, provided for context.
 * @param string       $post_type Optional. Post type to get the templates for. Default 'page'.
 * @return array Key is the template name, value is the filename of the template
 */
function get_page_templates($post = null, $post_type = 'page')
{
    return array_flip(wp_get_theme()->get_page_templates($post, $post_type));
}

WordPress Version: 3.9

/**
 * Get the Page Templates available in this theme
 *
 * @since 1.5.0
 *
 * @param WP_Post|null $post Optional. The post being edited, provided for context.
 * @return array Key is the template name, value is the filename of the template
 */
function get_page_templates($post = null)
{
    return array_flip(wp_get_theme()->get_page_templates($post));
}

WordPress Version: 3.7

/**
 * Get the Page Templates available in this theme
 *
 * @since 1.5.0
 *
 * @return array Key is the template name, value is the filename of the template
 */
function get_page_templates()
{
    return array_flip(wp_get_theme()->get_page_templates());
}