How to manipulate category templates

One of my favorite WordPress template features is the ability to customize category templates to cater specific categories of your choice.

Here’s my default category template. It simply displays excerpts:

category-default.png

Here’s my customize category template for category ID #2. This one is actually a theme gallery template:

category-custom.png

So, how do you manipulate category templates? Simple, duplicate your default

category.php

template (or

archive.php

in some cases), add a hyphen and a number to the name of the new file. For example:

category-2.php

. Then, start customizing the template for the new file.

The number attached to the file name should be the ID of the category that you want to target.

What's Next?
Related Posts

I don’t know if i’m just really tired, or not… but I’m confused as to what you would use this for, and how exactly you implement it. Please excuse my ignorance

Be default, you can use category.php as a template for all categories. To customize specific categories, you should create category-#.php files according to the ID of those categories that you want to customize for. The customizations go in the category-#.php file.

Very good! I guess this way you can also add a single post to appear at the top of a single category…

Wow,
I can see how that would be really useful. I honestly had no idea i could do that. Thanks a lot

This is really great and useful. Is this available through single page? Something like single-#.php?

I don’t think it is.

[…] How to manipulate category templates | WPDesigner Como hacer que distintas categorias se vean diferente en Wordpress (tags: wordpress howto categories archives webdev) […]

Sounds like a good idea, but I tried it - did not work hmm

don’t know if i’m just really tired, or not…

how does this work for themes that use the archive.php instead of category.php? I made an archive-18.php and it did not work for category 18. Please advise.

Also - can you please install the subscribe to comments plugin for wpdesigner.com? That’s a plugin every blog should have so you get notified when your comments are replied to.

thx!

Using category.php simply mean you’re being more specific. Without the presence of category.php, your blog uses archive.php as the default for all archive pages, including category archive pages.

create a category-18.php template

I named the file category-18.php (even though my theme uses archive.php instead of category.php) and it worked fine!

Hey,

Is there a way to make this work for all sub categories as well without having to create new files for each sub category id?

For instance:

Video Category
— City Video Category
— State Video Category

I am trying to style them all the same, but when I create new category as a sub category, I have to create a file for it.

Thanks,
Mike

i don’t know

ok. If I find out, I’ll be sure to post here

[…] Absolutely excellent tutorials - for me, nearly perfect, because half seem very useful - and the other half seem useful but totally over my head; here are a sample: […]

great text thank you

This is really great and useful.

Ashton:

b8HDK88MHtZUD

iyi günler sizlerin olsun

great text thanks.

Reply
Comment Policy
  • Theme support questions should be posted at the support forums.
  • Name and Email are required. Email is never published.
  • You grant this site perpetual license to reproduce your words and name/website in attribution.
  • Inappropriate comments will be removed at my discretion.
Close
Powered by ShareThis