Get the php template file from other theme folder

You can filter the template with the template_include filter. This example will filter the archive template for all archive pages. If you need to do this for a specific archive, use is_post_type_archive( $post_types ) as your condition. Put this in your functions.php file of your child theme.

function my_archive_filter( $template) {
    if ( is_archive() ) {
        return 'path/to/includes/archive-desc.php'; // Path to your child theme template.
    }
    else {
        return $template;
    }
}

apply_filters( 'template_include', 'my_archive_filter' );

Edit: It should now fall back to the default template if the custom template fails for some reason.

Leave a Comment