21

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.

  • Check if you have index.php in the root of your theme – Eugene May 1 '17 at 8:35
  • I'm having the same issue and tried everything you mentioned. Did you ever get a solution? – wckronholm May 4 '17 at 21:23
  • In my case i don't even see the file in the Theme Editor. @Tom have you solved it? – Ofir Baruch Nov 21 '17 at 12:42
29

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

  • 3
    You can also add this code to your functions.php or add it as a plugin to stop caching rather than editing core files: gist.github.com/westonruter/6c2ca0e5a4da233bf4bd88a1871dd950 – Bradley4 Nov 22 '17 at 21:47
  • 7
    Another simple solution is to bump the theme version in the style.css file as pointed by @ocean90 on the forum. – r1987 Nov 27 '17 at 18:53
  • 1
    @r1987 the style.css update worked! – Darye Nov 29 '17 at 23:31
  • For me the style.css was corrupt, so just update the file and you should be good – nodws Jun 18 '18 at 16:02
4

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

2

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.

2

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' );
1

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/

0

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

  • 1
    Never install a plugin from a link like this! It cannot be trusted. Always install plugins from trusted sources like the Wordpress Plugin Repository. – jasonlfunk Dec 17 '18 at 12:12
0

Have you accidentally moved or removed the style.css file from the theme root?

If so, it could be this - recreate the themes style.css to re-enable the template dropdown.

protected by Community Dec 7 '17 at 11:30

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.