Different styles for categories – need to edit a plugin

If I’m not totally missing some thing this should be achievable with a minor change to your code. You can not use post_class() in your code as it outputs/echos the classes. But there is get_post_class(), which does return the classes, but they are returned as a array. So you need to make a string out of it, to make use in your code. Lets do this just the way it is done for post_class() – see source – with PHP’s join(), but without echoing and adding the attribute itself.

Generally it would look like this:

$post_classes_string = join( ' ', get_post_class( $class, $post_id ) );

If you don’t need an extra class replace $class with ''. If you are in The Loop you can omit the $post_id, otherwise you will need it. The returned post classes contain some that look like category-* where the * will be the category name, which gives you every possibility to address your posts on category basis.

Last but not least, after you figured out above mentioned details, you should be able to simply add the classes by doing:

$srp_content .= '<div 
    id="' . $srp_post_id . '" 
    class="srp-widget-singlepost
         ' . $single_post_additional_classes . ' ' . $post_classes_string . '">';