I have this category-newbie.php template in my theme. And I have the category "newbie" in categories, but it is not using newbie it is using the category.php
EDIT:
I have this category-newbie.php template in my theme. And I have the category "newbie" in categories, but it is not using newbie it is using the category.php
EDIT:
Share Improve this question edited Sep 17, 2015 at 20:15 Kyle Calica-St asked Sep 17, 2015 at 18:38 Kyle Calica-StKyle Calica-St 601 silver badge13 bronze badges 10 | Show 5 more comments2 Answers
Reset to default 1So I actually solved this and forgot to write my solution.
So in my wordpress directory structure I have a categories directory. So I was putting my custom category template there. Apparently wordpress uses that categories directory for the built in categories or something and doesn't check it for custom ones. I just added my custom-slug.php to the root of the theme and it works.
I dont really like it personally because it doesn't seem to organize, but they may have their reasons for that.
Since you are having so much trouble, here is a band-aid solution. There is nothing wrong with this solution it just isn't as handy as simply using the WordPress template hierarchy and renaming the file.
Have a look at is_category()
.
Something like this:
<?php
$newbieID = 1; // put the ID for the Newbie category
if( is_category($newbieID) ) {
// Put template code here for Newbie
} else {
// Put template code for all other categories
}
?>
You will likely have to include this in both the category.php
and archive.php
template files.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745185284a4615607.html
category
, or is it a term from a custom taxonomy – Pieter Goosen Commented Sep 17, 2015 at 18:45Categories
tab in the back end? – Pieter Goosen Commented Sep 17, 2015 at 19:01category-ID.php
. Where the ID is the ID # of the category. To find the ID, click to edit the category Newbie (Dashboard > Posts > Categories > Newbie), you'll see the ID in the URL, for example:...tag_ID=15...
,category-15.php
. – deflime Commented Sep 17, 2015 at 19:04