[wp-trac] [WordPress Trac] #56762: PHP file being ignored in block theme hierarchy
WordPress Trac
noreply at wordpress.org
Wed Oct 19 10:28:04 UTC 2022
#56762: PHP file being ignored in block theme hierarchy
---------------------------+------------------------------
Reporter: ryanpluckrose | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 6.0.2
Severity: major | Resolution:
Keywords: needs-patch | Focuses: template
---------------------------+------------------------------
Comment (by willecs):
I found that putting the php template into the root of the theme
directory, it then works, however this does not work for php template
parts.
I added a filter to 'theme_file_path' to make this work.
{{{#!php
<?php
function test_theme_file_path($path, $file)
{
if (file_exists($path)) {
return $path;
}
$file = str_replace('.html', '.php', $file);
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$path = get_stylesheet_directory();
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$path = get_stylesheet_directory() . '/' . $file;
} else {
$path = get_template_directory() . '/' . $file;
}
return $path;
}
add_filter('theme_file_path', 'test_theme_file_path', 10, 2);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56762#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list