How to display only 3 main categories, separated by commas, since they are marked in the post?

by Omniatom   Last Updated February 27, 2019 19:08 PM

I want to display only 3 categories (Ex: horses, dogs, birds), names only and comma separated, in my Post, since one of them, two or all tree are marked in the post.

if ( 'in_category('horses') ) {
    echo "horses";
} ?></span><span><?php
if ( in_category('dogs') ) {
    echo "dogs";
} ?></span><span><?php
if ( in_category('birds') ) {
    echo "birds";

Related Questions

How to create a WP_list_table into a plugin

Updated December 04, 2017 20:08 PM

Pull the category name in category.php out of the loop

Updated October 02, 2017 10:08 AM