Skip to content

Commit f73bfb9

Browse files
committed
Themes: Add a new taxonomy template.
This uses the same cascade as tags and categories so the check will first be for the slug first, then the term ID, In classic themes, you can now use term IDs when creating taxonomy templates. With `taxonomy-$taxonomy-{$term->term_id}.php` templates you don't need to worry about templates breaking if you rename the `Oakland Athletics` term to `Athletics` the way you do if you use slug based template names. Props swissspidy, sebastian.pisula, jorbin, theMikeD. Fixes #35326. git-svn-id: https://develop.svn.wordpress.org/trunk@60994 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4f3c923 commit f73bfb9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/wp-includes/template.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,24 @@ function get_tag_template() {
323323
* The hierarchy for this template looks like:
324324
*
325325
* 1. taxonomy-{taxonomy_slug}-{term_slug}.php
326-
* 2. taxonomy-{taxonomy_slug}.php
327-
* 3. taxonomy.php
326+
* 2. taxonomy-{taxonomy_slug}-{term_id}.php
327+
* 3. taxonomy-{taxonomy_slug}.php
328+
* 4. taxonomy.php
328329
*
329330
* An example of this is:
330331
*
331332
* 1. taxonomy-location-texas.php
332-
* 2. taxonomy-location.php
333-
* 3. taxonomy.php
333+
* 2. taxonomy-location-67.php
334+
* 3. taxonomy-location.php
335+
* 4. taxonomy.php
334336
*
335337
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
336338
* and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'.
337339
*
338340
* @since 2.5.0
339341
* @since 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the
340342
* template hierarchy when the term slug contains multibyte characters.
343+
* @since 6.9.0 Added `taxonomy-{taxonomy_slug}-{term_id}.php` to the hierarchy.
341344
*
342345
* @see get_query_template()
343346
*
@@ -357,6 +360,7 @@ function get_taxonomy_template() {
357360
}
358361

359362
$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
363+
$templates[] = "taxonomy-$taxonomy-{$term->term_id}.php";
360364
$templates[] = "taxonomy-$taxonomy.php";
361365
}
362366
$templates[] = 'taxonomy.php';

0 commit comments

Comments
 (0)