Uses
Uses | Description |
---|---|
wp-includes/theme.php: wp_get_theme() | Gets a WP_Theme object for a theme. |
wp-includes/class-wp-theme.php: WP_Theme::get_page_templates() | Returns the theme’s post templates for a given post type. |
Gets the page templates available in this theme.
(WP_Post|null) (Optional) The post being edited, provided for context.
Default value: null
(string) (Optional) Post type to get the templates for.
Default value: 'page'
(string[]) Array of template file names keyed by the template header name.
The function searches all the current theme’s template files for the commented “Template Name: name of template”. See also wp_get_theme() and the wp_get_theme()->get_page_templates() method of the WP_Theme class.
File: wp-admin/includes/theme.php
function get_page_templates( $post = null, $post_type = 'page' ) { return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); }
Version | Description |
---|---|
4.7.0 | Added the $post_type parameter. |
1.5.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_page_templates