After hours of unfruitful Googling, I am asking for your help on this issue.
My objective is to display only 1 category with get_the_category if the category ID matches the ID or slug set in the get_the_category function. Basically I'm asking for something like this: let's say there's a category titled "important". I want to exclude all other categories assigned to the post and only show "important" if the post is within that category. If the post isn't in important, nothing should be displayed. This should be too hard, but I could figure it out.
Here's the closest thing I found to this, but it only displays the first category for the post, no option for manual selection by ID or slug:
<?php
$category = get_the_category();
if($category[0]){
echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';
}
?>
Thank you for your contributions.