After renaming the files of my templates and inside the file with php, it is looking for the old templates. The dropdown is no longer available. Why is this happening and how to fix that?
The only files i modified is the template-parts
folder inside the child theme. I did not touch the class-wp-theme.php
where it is the warning.
After renaming the files of my templates and inside the file with php, it is looking for the old templates. The dropdown is no longer available. Why is this happening and how to fix that?
The only files i modified is the template-parts
folder inside the child theme. I did not touch the class-wp-theme.php
where it is the warning.
Share Improve this question edited Nov 23, 2017 at 16:56 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Nov 22, 2017 at 9:02 csandreas1csandreas1 2063 silver badges11 bronze badges 4
- 2 this is a known bug within WordPress 4.9 where WordPress saves the template file name and doesn't gracefully fail when the template is no longer there – Alex Older Commented Nov 22, 2017 at 9:06
- Everything is fixed now, i just needed to wait for some reason. – csandreas1 Commented Nov 22, 2017 at 10:28
- To speed up this process you can change your theme's version because its cached with the theme version. Later you can just change it back – Wilco Commented Nov 22, 2017 at 11:03
- @Wilco okay i will try that, the next time i may come in this problem. I hope this bug will get fixed though soon. – csandreas1 Commented Nov 22, 2017 at 14:03
1 Answer
Reset to default 2If you have WP-CLI installed, try to run wp cache flush
or
you can put this code into your functions.php
function fix_template_caching( WP_Screen $current_screen ) { if ( ! in_array( $current_screen->base, array( 'post', 'edit', 'theme-editor' ), true ) ) { return; } $theme = wp_get_theme(); if ( ! $theme ) { return; } $cache_hash = md5( $theme->get_theme_root() . '/' . $theme->get_stylesheet() ); $label = sanitize_key( 'files_' . $cache_hash . '-' . $theme->get( 'Version' ) ); $transient_key = substr( $label, 0, 29 ) . md5( $label ); delete_transient( $transient_key ); } add_action( 'current_screen', 'fix_template_caching' );
Reference: Fix for theme template file caching https://gist.github/westonruter/6c2ca0e5a4da233bf4bd88a1871dd950
Hope this helps!
:)