shortcode – my-taxonomy-slug (not term slug)

This shortcode displays the slug of the taxonomy, not the term slug. It can be used in an archive or taxonomy view.
For example, in the case of the custom taxonomy ‘movies’, with terms like ‘crime’, ‘drama’, ‘anime’, if you use it in the archive (ex: URL /movies/drama/), the output will be ‘movies’.

// Shortcode taxonomy slug
function my_taxonomy_slug() {
    global $wp_query;
    
    $taxonomy = $wp_query->queried_object->taxonomy;
    return $taxonomy;
}
add_shortcode('my-taxonomy-slug', 'my_taxonomy_slug');