Custom templates not showing up in template dropdown

I’ve got some problems with templates in WordPress (multisite). I’ve created a file in the root of my child-theme folder (template-test.php)

<?php
/**
* Template Name: Test template
*
*/
?> 

<?php get_header(); ?>

<?php get_footer(); ?>

This template is not showing up in the templates dropdown when creating a new page, or editing an existing page. The only thing in the dropdown is the ‘default template’.

What I’ve tried so far:
– Disabling and enabling my theme
– Flush permalinks
– Check permissions of my files
– Check if style.css is in the root of the template folder (it is)

I’ve tried the same file on another WordPress installation, and there it works fine.

7

Just in WordPress 4.9 there’s this bug: https://core.trac.wordpress.org/ticket/42573 causing the template files to only be rescanned once every hour.

To fix (until they release a new WP version with this changed), download the patch on that bug ticket and make the changes from the patch to wp-includes/class-wp-theme.php.

Hope this saves someone the 2 hours I wasted on this..

Leave a Comment