i want to make wordpress use a specific template
for all sub-categories in a specific category.
i think it can be done with a conditional that
that says: if parent category is...
then use this template...
does is one know if there is a way to do that?
thank's
Have you had a look at the conditional tags? The function is_category should help you here.
I did, but isnn't that check's what is the category it self,
and not it's parent category?
Oh sorry, didn't notice that you wanted the parent category. What about this?
<?php
$category = get_the_category();
if ($category->category_parent == 42) {
# use special template
}
?>
I don't know it dosen't work,
I need to put it in the "category.php"
like that:
<?php
$category = get_the_category();
if ($category->category_parent == 9) {
# use special template
}
<?php include (TEMPLATEPATH . '/category-9.php'); ?>
?>
right?
Put the line with the call to include inside the if statement - between the curly brackets - and remove the extra "<?php"/"?>" from this line.
Oh im so stupid, you right,
But it's still dosen't work,
it looks likt that now:
<?php
$category = get_the_category();
if ($category->category_parent == 9) {
include (TEMPLATEPATH . '/category-9.php');
}
?>
right?
Hm, have you read this? Maybe you just need to name the file with the above snippet right.
I did read it,
but that means I need to make php files
for all the categorys...
There must be another easy way to that, don't you think?
I think i got a solution,
it's not so simple, but what can i do... ?!
it's here:
http://brassblogs.com/blog/making-child-categories-recognize-parent-displays
if any-one intrested...
anyway thank you very much chschenk !