Better way to exclude category output for post/pages?

If the URL being “hard-coded” is the problem you can use get_category_link

foreach((get_the_category()) as $cat) {
    if ($cat->cat_ID !='12')
        echo '<a href="'.get_category_link($cat->cat_ID).'"> | ' . $cat->cat_name . '</a>';
}

tech