get_page_templates

SummerySummery

Gets the page templates available in this theme.

Syntax

get_page_templates( WP_Post|null $post = null, string $post_type = 'page' )

ParametersParameters

$post

(WP_Post|null) (Optional) The post being edited, provided for context.

Default value: null

$post_type

(string) (Optional) Post type to get the templates for.

Default value: 'page'

ReturnReturn

(string[]) Array of template file names keyed by the template header name.

SourceSource

File: wp-admin/includes/theme.php

 *
 * @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'.

ChangelogChangelog

Changelog
Version Description
4.7.0 Added the $post_type parameter.
1.5.0 Introduced.
Scroll to Top