Loop through categories

$categories = get_the_category(); //Returning an array with all the categories for the current post
//if we have any categories then we’ll copy into an array
if ($categories) {
$class_names = array();
foreach($categories as $category) {
// do something with $category here…
}

}

Add your comment