Gets the page templates available in this theme.
$postWP_Post|nulloptional
Default:null
$post_typestringoptional
'page'.Default:'page'
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.
function get_page_templates( $post = null, $post_type = 'page' ) {
return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_page_templates