Dynamic archive template taxonomy/filter


I need to build a common archive template for different CPTs sharing the same layout but different taxonomies.

I can dynamically get the right post type by selecting “post type” in the query post type dropdown, but it seems we can’t use a return function in the taxonomy query dropdown, so I tried with the shortcode:


(Shortcode echoes get_object_taxonomies(get_post_type())[0] which is the slug of the first (and unique) taxonomy for each CPT.)

But then, it seems impossible to dynamically set the taxonomy in filter block:


I tried to manually set the filter taxonomy but on the corresponding CPT archive page, it doesn’t seem to work.

So I guess my shortcode hack for dynamic taxonomy doesn’t work.

So in the end, is the solution to duplicate query and filter blocks for each CPT and use conditions?

Because then each change in query template or filter has to be repeated for each CPT.

Maybe I’m missing something?