How can I get the first category (linked to the category archive page) of a post excluding the category called 'featured'? I found various solutions but I can't combine them properly.
Thanks
UPDATE:
This is what I ended up using:
$category = get_the_category();
$cat_id = get_cat_ID( $name );
$link = get_category_link( $cat_id );
if($category[0]->cat_name == "featured") {
echo '<a href="'. esc_url( $link ) .'"">'. $category[1]->cat_name .'</a>';
} else {
echo '<a href="'. esc_url( $link ) .'"">'. $category[0]->cat_name .'</a>';
}
get_categoriesdefaults to sorting by ID, which would mean sorting by category creation order. That can be changed to sort by other fields, like "name". You can also reverse the return set. – s_ha_dum Feb 6 at 15:26