exbionic,
Just did something similar. What I wanted was load a particular sidebar for each parent category. What makes the job easier is if you number the single page the same as your category you can get the category number, then it is a simple matter of loading the page–it would look something like ‘singe’.<?php $cat ?>.’.php’
Hi Michael,
Thanks for your reply.
<?php cat_is_ancestor_of(cat1, cat2); ?>
I don’t think this is what I am looking for as, if I’m reading this right, you would need to declare all of the child categories in the function?
I am thinking that, maybe, I should have included more detail in my original question.
The site I am building is for a TV production company and contains a lot of video clips of their work. I have set up my categories and child categories as follows:
Directors
___Director Name 1
___Director Name 2
___Director Name 3
___etc.
Genres
___Comedy
___Drama
___Animation
___etc.
My problem is that I need to have a different template shown if the viewer is visiting a Director page than when viewing a Genre page. Obviously when I say ‘page’ I mean web page and not a WordPress ‘Page’.
It would be easy (if not a little tedious) to set up category-x.php files for each of the categories but the list of directors is not finite and the client will want to add to it as they work with new directors.
Therefore it would be easier if I could just get WordPress to check to see if the current category being viewed is a child of either ‘Directors’ or ‘Genres’.
Sorry for the long-winded post! Many thanks again for any help.
Cheers.
Hi Storyman,
I never noticed you reply before posting my reply to Michael!
The point at which I need the template is not for a single page but for a complete list of posts in any given category i.e http://www.foo.com/?cat=12 etc.
I pull in a thumbnail and a link to each post in that category which contains the video clip.
Hope that makes sense.
Thanks for your reply 😀
I’ve, in a sense, managed to solve this problem.
It occured to me that although the child categories of Directors were not finite, the child categories of Genres were. Therefore I just created the requisite number of ‘category-x.php files and let category.php be the template for all director categories.
I am goingto leave this post as un-resolved though as some kind of if/else for children of parent categories would be a much more elegant solution.
If anyone can come up with anything here I would certainly be interested in seeing it.
Cheers.