I found a solution.
First of all, the best way seems to not use do_shortcode
direclty in the php.
You can know more here.
So…
taxonomy-mytaxonomy.php
<?php
defined( 'ABSPATH' ) || exit;
get_header( );
?>
<!-- Content -->
<div id="content" class="content" role="main">
<?php
the_archive_description( '<div class="taxonomy-description">', '</div>' );
if ( have_posts() ) {
$queried_object = get_queried_object();
$term_slug = $queried_object->slug;
$atts = [
'attr1' => "value1"
];
echo ListCPTShortcode::getCallBack( $atts, null, "my-shortcode" );
} else {
get_template_part( 'no-results', 'search' );
}
?>
</div><!-- #content -->
<?php get_footer(); ?>
To enqueue scripts and styles, I did this
my-theme/functions.php
function my_shortcode_category_load( $content ){
$current_post = get_queried_object();
if( !empty( $current_post ) && isset( $current_post->taxonomy ) && $current_post->taxonomy === "mytaxonomy" ){
wp_enqueue_style(...);
wp_enqueue_script(...);
}
return $content;
}
add_filter( "the_content", "my_shortcode_category_load" );