WordPress at a glance

get_page_templates() WP 1.0

Get the Page Templates available in this theme

No Hooks.

Return

String[]. Array of template file names keyed by the template header name.

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'

Changelog

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

Code of get_page_templates() WP 5.5.1

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

From category: Other Theme Functions

No comments
    Log In . Register