Apply custom taxonomy archive template to children

admin2025-01-07  4

There is a slight problem that I cannot figure out by myself:

I created a custom post type (tours) with custom taxonomy (tour categories). I have created a taxonomy-tour-categories.php to display an archive page for each tour category. Works perfect.

I have a tour category (School tours) which needs a different layout, so I added a second template taxonomy-tour-categories-shool-tours.php with my desired layout. Again it works perfect.

The problem is that the 'school tours' tour category has its own subcategories (like 'workshops', 'science labs' and so on) which I would like to be displayed by the taxonomy.tour-categories-school-tours.php template, but are displayed by the taxonomy.tours-categories.php template. Why that?

I thought that wordpress - when a template file for a specific term is missing - would fall back to the immediately above level template file (in this case taxonomy.tours-categories-school-tours.php). What am I missing?

Thanks for your help!

There is a slight problem that I cannot figure out by myself:

I created a custom post type (tours) with custom taxonomy (tour categories). I have created a taxonomy-tour-categories.php to display an archive page for each tour category. Works perfect.

I have a tour category (School tours) which needs a different layout, so I added a second template taxonomy-tour-categories-shool-tours.php with my desired layout. Again it works perfect.

The problem is that the 'school tours' tour category has its own subcategories (like 'workshops', 'science labs' and so on) which I would like to be displayed by the taxonomy.tour-categories-school-tours.php template, but are displayed by the taxonomy.tours-categories.php template. Why that?

I thought that wordpress - when a template file for a specific term is missing - would fall back to the immediately above level template file (in this case taxonomy.tours-categories-school-tours.php). What am I missing?

Thanks for your help!

Share Improve this question edited Mar 5, 2013 at 13:23 kaiser 50.8k27 gold badges150 silver badges244 bronze badges asked Mar 5, 2013 at 12:59 GianGian 1 1
  • Please always read your question again before posting. Else you can use the "edit" link on the bottom of the question to fix grammar, spelling and MarkUp. Thanks. – kaiser Commented Mar 5, 2013 at 13:25
Add a comment  | 

1 Answer 1

Reset to default 0

As you can see in this image, template hierarchy limits to taxonomy-$taxonomy-$term.php.

I don't know why a subterm falls back to taxonomy-$taxonomy.php, but I guess it searches for a taxonomy-$taxonomy-$term.php in wich $term would be workshops, science labs and so on. And since those don't exist (I suppose), it falls back on taxonomy-$taxonomy.php.

You could make use of a workaround in your taxonomy-$taxonomy.php file wich loads the requested taxonomy-$taxonomy-$term.php file when the $term has a parent $term.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736258737a536.html

最新回复(0)