Thank you very much for the quick-and-detailed reply, Shaon!
Your sample was very helpful! I only had to change two items to get it working: replace the double quotes in rel=’nofollow’ to single quotes (it was simply breaking everything due to the syntax error in this line); and replace $package[‘category’] with $vars[‘category’] (which is the proper variable name inside this function.
I also did another change to output a simple list of category names, without links, since in my case I only name to display the category names. Below is the final code I used, in case others find it useful:
function wpmp_package_cats($vars){
$categories = maybe_unserialize(get_option('_fm_categories'));
$cats = @maybe_unserialize($vars['category']);
$cats_output = '';
foreach($cats as $cat){
$cats_output .= ''.$categories[$cat][title].'';
}
if ($cats_output != '') {
$cats_output = ''.$cats_output.'';
}
$vars['the_categories'] = $cats_output;
return $vars;
}
add_filter('wdm_before_fetch_template',"wpmp_package_cats");