Add the following code to your functions.php file. Replace the array with the correct templates for your site.
CONST CUSTOM_PAGE_TEMPLATES = array(
array('slug' => 'home', 'label' => 'Home'),
array('slug' => 'about', 'label' => 'About'),
array('slug' => 'contact', 'label' => 'Contact')
);
Add the rest of the code to your functions.php file.
/**
* Add file-less page templates to the page template dropdown
*/
add_filter('theme_page_templates', function($page_templates, $wp_theme, $post) {
foreach(CUSTOM_PAGE_TEMPLATES as $template) {
// Append if it doesn't already exists
if (!isset($page_templates[$template['slug']])) {
$page_templates[$template['slug']] = $template['label'];
}
}
return $page_templates;
}, PHP_INT_MAX, 3);
The templates will now be selectable in the Page Attributes.
