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.

Solutions Collecting From Web of "Custom templates not showing up in template dropdown"

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..

There’s a bug in WordPress 4.9.

I found this temporary plugin super straightforward. I plan on uninstalling it once they fix the bug, but it works great in the meantime!

Plugin: https://github.com/connorlacombe/WP-Clear-File-Cache

Templates can be deactivated by unsetting them from the wp_themes global variable before the template dropdown is loaded.

Run this code on the page to see what templates show up:

global $wp_themes;
$tema = wp_get_themes();
print_r($tema["child-theme folder name"]["Template Files"]);

If your template does not show up, the parent theme might have unset it from the array.

It might show up, if you run this code in front-end, as the parent theme might only unset it during the load of the admin editor page.

Download the parent theme and search the files for $wp_themes and wp_get_themes(); to find the location of that code.

Hopefully they’ve given you a way to prevent it using a filter, if not you might have to re-add the files in the child theme.
This could be helpful: http://www.wpexplorer.com/wordpress-page-templates-plugin/

I also had this problem with a site on WordPress Multisite and was able to fix it by following these steps:

  1. Go to http://example.com/wp-admin/network/themes.php (replace example.com with your URL).
  2. Click the “Edit” link under the theme that’s causing you issues.
  3. In the right sidebar click the name of the template file that’s not showing up. For example, it might say “Events Page Template (template_events.php)”.
  4. Don’t make any edits to the file and click the blue “Update File” button.
  5. Refresh the page’s edit screen where you’re trying to set the template and it should now display in the dropdown.

If this doesn’t do the trick for you I’d suggest checking out http://vanseodesign.com/wordpress/wp-page-templates-dropdown/. There are some other possible solutions in there.

Good luck.

Make sure you have index.php in your main theme. Main theme must have index.php. I have same issue, and this was the case.
Checked by:

function testate(){
    global $wp_themes;
    $tema = wp_get_theme();
    echo '<pre>';
    print_r($tema);
    die;
}

add_action('init', 'testate' );

Fix page template not showing in dropdown menu
please activate below plugin to fix (instead of changing wordpress core files)

Below is link for download
https://drive.google.com/file/d/1ycHQGdc_vQtvtfBaznJp1KRsEbcoRwxB/view?usp=sharing