"in_category()" function help
-
Hello,
first of all i want to Thank You in advance for the help!And here’s my question:
On the index page i want to place a small icon next to the post name for posts that are in specific category. Lets say that i have this categories structure:
Main Cat1 --Sub Cat1 --Sub Cat2 --Sub Cat3 Main Cat2 Main Cat3 etc.
So i need all posts that are in sub-catgories 1,2 and 3 to have this icon.
The simple solution:<?php if ( in_category( array(Sub Cat1 ID,Sub Cat2 ID,Sub Cat3 ID)) {echo "<img src='ICON URL'w>";} ) ?>
But in this case i should add every new sub-catgory manually.
I tried this:
<?php if ( in_category(Main_Cat1 ID) {echo "<img src='ICON URL'w>";} ) ?>
But its not working.
If anyone can suggest a solution for this?
Thanks!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘"in_category()" function help’ is closed to new replies.