[wp-trac] [WordPress Trac] #37655: [Template Hierarchy] category-slug.php cannot be properly loaded when slug is not English
WordPress Trac
noreply at wordpress.org
Sun Aug 14 10:07:07 UTC 2016
#37655: [Template Hierarchy] category-slug.php cannot be properly loaded when slug
is not English
--------------------------+-----------------------------
Reporter: withgjr | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.5.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
This problem can be reproduced very easily:
1. Create a category using the language other than English. (In my case,
Chinese)
2. And create a category-slug.php file.
3. And then you can see the Wordpress can not find the right template to
load.
This problem is caused by the function 'get_category_template' in the wp-
includes/template.php file.
Just change this line:
{{{#!php
<?php
if ( ! empty( $category->slug ) ) {
$templates[] = "category-{$category->slug}.php";
$templates[] = "category-{$category->term_id}.php";
}
}}}
To:
{{{#!php
<?php
if ( ! empty( $category->slug ) ) {
$decoded_slug = urldecode($category->slug);
$templates[] = "category-{$decoded_slug}.php";
$templates[] = "category-{$category->term_id}.php";
}
}}}
And this problem can be solved.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37655>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list