template_include doesn't work with child theme
I am using this code and it works perfectly but it does not work if I activate the child theme how can I solve?
add_filter( 'template_include', 'wpse_template_include' );
function wpse_template_include( $template ) {
// Handle taxonomy templates.
$taxonomy = get_query_var( 'taxonomy' );
if ( is_tax() $taxonomy ) {
$file = get_theme_file_path() . '/template-parts/taxonomies/taxonomy-' . $taxonomy . '.php';
if ( file_exists( $file ) ) {
$template = $file;
}
}
return $template;
Topic template-include child-theme Wordpress
Category Web