1

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

category list

EDIT:

permalinks

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 Commented Sep 17, 2015 at 18:45
  • sorry a bit new to wordpress. I made up "newbie" if thats what you mean. Commented Sep 17, 2015 at 18:53
  • Is this under the Categories tab in the back end? 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) Commented Sep 17, 2015 at 19:06

2 Answers 2

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.

4
  • sounds like the theme you use is the unorgenized (or you misunderstood something there). Main templates should always be at the root of the theme otherwise the wordpress documentation will not be useful. Then in the files you can include other files from whatever location you want, but the base should be there. Commented Oct 14, 2015 at 20:12
  • yeah the main template is at the theme its my other templates for slugs not being seen, only at the root they are seen. I didn't set it up and im only hired to edit the templates. Or are you saying that all templates for a category have to be at the root and then i can set other pieces of the template in whatever location? Commented Oct 14, 2015 at 20:19
  • You can write code to place any file whenever you want by overriding the templating core system (not as hard as it might sound), the problem is that when a new developer comes in, he will have to spend time understanding the basics of the system, which it sounds like what happened to you. Commented Oct 14, 2015 at 20:44
  • yup exactly what is happening i have some code navigating the file system, i just wished i had it using it the way wordpress would just pick it up by its nature. but im still learning :D Thanks! Commented Oct 14, 2015 at 20:49
0

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.

1
  • alright, man i have no idea why i am the only one having this problem! Commented Sep 17, 2015 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.