categories - Category-slug.php not being used

I have this category-newbie.php template in my theme. And I have the category "newbie" in categories, but it i

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
  • Are you sure that the term is actually a term from the build in taxonomy category, or is it a term from a custom taxonomy – Pieter Goosen Commented Sep 17, 2015 at 18:45
  • sorry a bit new to wordpress. I made up "newbie" if thats what you mean. – Kyle Calica-St Commented Sep 17, 2015 at 18:53
  • Is this under the Categories tab in the back end? – Pieter Goosen Commented Sep 17, 2015 at 19:01
  • Rename the file to category-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
  • yes it is from the categories tab in the backend. I cant find the ID number even when I go to categories listed under post, I dont see any id numbers or when I click to edit the category. (Let me also iterate that I am not a full admin on this site) – Kyle Calica-St Commented Sep 17, 2015 at 19:06
 |  Show 5 more comments

2 Answers 2

Reset to default 1

So 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

相关推荐

  • categories - Category-slug.php not being used

    I have this category-newbie.php template in my theme. And I have the category "newbie" in categories, but it i

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信