get_the_category
returns an array with all the categories
$categories = get_the_category();
foreach ($categories as $category){
echo '<a class="post-item" href="' . get_category_link($category->term_id) . '">' . $category->cat_name . '</a>';
}
Tha code should work, you can modify it to add the title
Also, calling the_category
echoes the result, that why i’m using the this function