Trying to do what I thought would be pretty simple.
Wanted to add some conditional code based on the post category to the sidebar.
Code I am using is:
<?php global $category_id;
if ($category_id == 259) {echo 'YYY'; }
else {echo 'NNN'; }; ?>
Does not seem to be working correctly.
Not sure where I am going wrong.
Anyone see what I'm missing?
Driftless1
Member
Posted 13 years ago #
Not sure that you've actually got anything in your variable $category_id
Try using the is_category() function inside a loop... or in_category()
<?php if (in_category('259')
echo 'YYY';
else
echo 'NNN';
?>
http://codex.wordpress.org/Template_Tags/in_category
Thanks Driftless1.
Ended up with a plugin work around.
I think the problem was that it wasn't in the loop.
// closed