You misunderstand what page_template
does. It does not create a new template that you will “show up” somewhere and that you can use. It replaces the page.php
template provided by the theme.
I think that what you want is template_redirect
:
function custom_page_template( $page_template ) {
if (is_home()) {
get_header();
echo 'do stuff';
get_footer();
}
}
add_filter( 'template_redirect', 'custom_page_template' );
Or template_include
:
function custom_page_template( $page_template ) {
if (is_home()) {
$page_template = plugin_dir_path( __FILE__ ) . 'custom-page-template.php';
return $page_template;
}
}
add_filter( 'template_include', 'custom_page_template' );