in my theme, while outputting all posts, im trying to determine if a post belongs to a certain category or not. if so, show an icon. i can get the id of each posts's category by using $cat = get_cat_ID( 'up, down, left, right' ); PHP: up, down, left, right is the name of the category i want to check and see if the post is in. now the function, 'the_category()' outputs the category name. is there something that essentially the same but returns a variable instead of echoing it? im confused as heck here. and wordpress really isnt my area of expertise so any help would be appreciated.
I don't know WordPress that well either but you can probably modify the get_cat_id() function to return the value instead of echoing it. If you can give me (us?) the code to that function that would help .
i solved it using get_the_category(). here's the code i used to set a classname based on what category the post is in so if anyone else is wandering how to do it, here you go. <?php $udlr_cat = get_cat_ID( 'up, down, left, right' ); $ff_cat = get_cat_ID( 'flammable firewall' ); $cats = get_the_category(); foreach($cats as $cat) $cid = $cat->cat_ID; if ( $cid == $udlr_cat ) $clname = "udlr"; else if ( $cid == $ff_cat ) $clname = "ff"; ?> PHP: thanks for the input though, cody. it's appreciated.