get category outside the loop — code difficulty
-
I’m using a plugin to assign categories to pages. Works beautifully. On the page template I’m able to display css according to the category. There is a sidebar that is included and I’d like to display a certain image depending on what category the page or post is in.
This is the code that works on the page template:
‘<?php if ( in_category(9) ) {
echo ‘thing’;
} elseif ( in_category(8) ) {
echo ‘thing2’;
} else {
echo ‘something else’;
}
?>’but it breaks the display when put in the sidebar.
Have searched and tried lots of things for getting the current category outside the loop but am having the devil of a time. Help greatly appreciated.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘get category outside the loop — code difficulty’ is closed to new replies.