And So I am attempting to give a "-none" to some class for any publish if it's inside a specific category in Wordpress. So like allows say should i be viewing a publish which has a category id of seven, i would like a particular class entitled "example" switch to "example-none".
Here's my code:
<div class="example<?= is_category('events') ?'-none':'' ?><?= in_category('7') ?'-none':'' ?>">
The strange factor using the code is, it really works inside a page after i am viewing all of the posts inside a specific category. However when Time passes for an interior publish that's inside a specific category, the code doesn't work.
I'm while using in_category('7') tag to do this on the wordpress sidebar.
Any idea on which I'm doing wrong?
I'd take away the quotes round the id from the category:
This ought to be several, not really a string.
Thanks. i first got it working by using this code:
<div class="example<? wp_reset_query(); ?><?= in_category(7) ?'-none':'' ?>">