I am using this function to display categories specified to a post having gallery on the image attachment page.
<p>CATEGORY: <?php the_category(', '); ?></p>
The problem is that this function doesn't return anything. I have also used this way to display categories but no success:
<?php $categories = get_the_category();
$separator = ', ';
$output = '';
if($categories){ ?>
<span>CATERGORY:</span>
<?php foreach($categories as $category) {
$output .= '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
}
echo trim($output, $separator);
}
?>
Can anyone tell where problem lies???
Thanks

functions.phpis not recommended as this is not a Themespecific feature. – fischi Dec 27 '12 at 12:20