get_queried_object
is how you retrieve the term for the current category, although you have to be careful to check for this, as it may not be a category archive. It could be a date archive, or a tag archive, etc etc
At a minimum you should include an is_category
check:
https://developer.wordpress.org/reference/functions/is_category/
Reading the docs for is_category
also reveals it takes a parameter so not only can you check if it’s a category, you can use it to check if it’s a specific category.
You should also look into using locate_template
to grab the path to the file rather than dirname( __FILE__ )
. This is because the current code has no support for child themes or plugin overrides.
see https://developer.wordpress.org/reference/functions/locate_template/
Another solution would have been to use category-sport-fritid-parent.php
and then inside that file called get_template_part
to pull in a shared template file.
For reference, here is the official documentation for the filter you’re trying to use:
https://developer.wordpress.org/reference/hooks/type_template/
And post in the comments of that doc is an example doing exactly what you’re asking how to do:
https://developer.wordpress.org/reference/hooks/type_template/#comment-4683