So I am trying to add a "-none" to a class for a post if it is in a specific category in Wordpress. So like lets say if I am viewing a post that has a category id of 7, i want a certain class titled "example" change to "example-none".
Here's my code:
<div class="example<?= is_category('events') ?'-none':'' ?><?= in_category('7') ?'-none':'' ?>">
The weird thing with the code is, it works in a page when I am viewing all the posts in a specific category. But when I go to an interior post that is in a specific category, the code does not work.
I am using the in_category('7') tag to achieve this on a wordpress sidebar.
Any idea on what I am doing wrong?