Differing PHP Output per-Category
-
Hi all, I have a question for all of the PHP gurus out there…
I have a template that I am developing and I want to be able to display posts belonging to certain categories slightly differently. For instance, just say I have four categories – “quick”, “mobile”, “children”, “pets”. I want to display posts from the “quick” and “mobile” categories differently from the “children” and “pets” categories.
Initially I was working with CSS and a hack to enter the category names as class names for each post, which meant I could style them differently, but I have reached a point where I want to change the order of some elements – for instance, for some categories, I want to display the author name, posting date, and other metadata before the body of the post, and for others I want to display them after, which is beyond the ability of mere CSS.
It occurs to me that what I need is some sort of <?php if> statement, and then the use of some kind of string function to search the categories string for each post for the relevant category, but that is beyond my ability.
Can anyone provide me any pointers?
- The topic ‘Differing PHP Output per-Category’ is closed to new replies.