how do I get the cat ID inside the Template. Very important: I can not do it by the name, because we have muliple cats with the same name. Only the slug is different. If I'd get the slug, it would be okay, too. But like I said: I can not use the Cat title.....
|
|
|||
|
|
|
Unless I am misunderstanding the question, I think you can also add the category id/slug to the body class:
|
|||
|
|
|
Umm, I can't comment yet, but VicePrez's answer does work. The following works just fine on a category archive page (although you probably want to do something other than just echo it):
EDIT: Scratch that, it worked for me until I came across a category that didn't have a post, then it picked up the subcategory instead of the main category. You can't rely on get_the_category on a category template page. |
||||
|
|
|
You could use Example:
You could use:
to view the array of objects that are returned. |
|||||||||
|
|
@Jan Fabry's response is actually the correct answer, here's why: Since Wordpress allows multiple categories for a post, using That's why it's better to use |
|||
|
|
|
|||||
|