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


Solved! just need to change

get_theme_file_path()

to

get_template_directory()

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.