WP_Theme get_page_templates(), :
apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
1103 -wp-theme.php
, wordpress post page post_type s,
add_filter( "theme_post_templates", ... add_filter( "theme_page_templates",...
.
codex "Used By" :
wp-admin/includes/template.php: page_template_dropdown()
wp-admin/includes/meta-boxes.php: page_attributes_meta_box()
, /wp-admin/.
, :
* Filters list of page templates for a theme.
*
* The dynamic portion of the hook name, `$post_type`, refers to the post type.
* @since 4.7.0 Added the `$post_type` parameter.
*
* @param array $post_templates Array of page templates. Keys are filenames,
* values are translated names.
* @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null.
* @param string $post_type Post type to get the templates for.
, uri get_theme_file_path(), , .
function deep_templates( $post_templates, $theme, $post, $post_type )
$post_templates['/folder/folder/folder/file.php'] = "Page Style One";
$post_templates['/folder/other-folder/file.php'] = "Page Style Two";
return $post_templates;
add_filter( 'theme_page_templates', 'deep_templates' );
/
add_filter( 'theme_post_templates', 'deep_templates' );
add_filter( 'theme_my-custom-cpt_templates', 'deep_templates' );