Languages: English • 日本語 (Add your language)
This function returns the available page templates in the currently active theme. It searches all the current theme's template files for the commented Template Name: name of template. See also get_current_theme() and the wp_get_theme()->get_page_templates() method of the WP_Theme class.
<?php $templates = get_page_templates(); ?>
None.
The following code snippet loops through the available page templates and outputs their template names and the filenames.
<?php $templates = get_page_templates(); foreach ( $templates as $template_name => $template_filename ) { echo "$template_name ($template_filename)<br />"; } ?>
<?php print_r(get_page_templates());?> Array ( [Sidebar] => sidebar.php [Category] => category.php [Page] => page.php [Home] => home.php [Single] => single.php [Comments Popup] => comments-popup.php [Footer] => footer.php [Header] => header.php [Index] => index.php [Contact] => contact.php [Home-Intro] => home-intro.php [Sidebar Left] => sidebar-left.php [Sidebar Right] => sidebar-right.php [TOC Home] => page-client-toc.php [Search Form] => searchform.php [Main-Navbar] => main-navbar.php [Bookmarks] => page-bookmarks.php )
get_page_templates() is located in wp-admin/includes/theme.php
.