Make WordPress Core

Ticket #35326: 35326-taxonomy-template-by-termid.diff

File 35326-taxonomy-template-by-termid.diff, 875 bytes (added by sachinrajcp123, 9 months ago)
Line 
1Index: src/wp-includes/template-loader.php
2===================================================================
3--- src/wp-includes/template-loader.php (revision 60000)
4+++ src/wp-includes/template-loader.php (working copy)
5@@
6 if ( is_tax() ) {
7        $term = get_queried_object();
8 
9        if ( $term && ! is_wp_error( $term ) ) {
10                $templates = array();
11 
12-               $templates[] = "taxonomy-{$term->taxonomy}-{$term->slug}.php";
13+               // Add new template based on term_id for better stability when slugs change.
14+               $templates[] = "taxonomy-{$term->taxonomy}-{$term->term_id}.php";
15+               $templates[] = "taxonomy-{$term->taxonomy}-{$term->slug}.php";
16                $templates[] = "taxonomy-{$term->taxonomy}.php";
17                $templates[] = 'taxonomy.php';
18                $templates[] = 'archive.php';
19 
20                $template = locate_template( $templates );
21                if ( $template ) {
22                        load_template( $template );
23                        return;
24                }
25        }
26 }