<?php
add_filter( 'theme_page_templates', 'pluginname_template_as_option', 10, 3 );
function pluginname_template_as_option( $page_templates, $theme, $post ){
$page_templates['template-landing.php'] = 'Example Landing Page';
return $page_templates;
}
add_filter( 'template_include', 'pluginname_load_template', 99 );
function pluginname_load_template( $template ) {
global $post;
$custom_template_slug = 'template-landing.php';
$page_template_slug = get_page_template_slug( $post->ID );
if( $page_template_slug == $custom_template_slug ){
return plugin_dir_path( __FILE__ ) . $custom_template_slug;
}
return $template;
}