Skip to content

Commit e3b7bff

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. Built from https://develop.svn.wordpress.org/trunk@60994 git-svn-id: http://core.svn.wordpress.org/trunk@60330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent a912bcb commit e3b7bff

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

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';

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-alpha-60993';
19+
$wp_version = '6.9-alpha-60994';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)