Printing the slug of a category inside the loop

Description

This code will print the slug of a categories inside the loop

This code will print the slug of a categories inside the loop

PHP Source Code

                        
                          <?php
$categories = get_the_category();
$cls = '';

if ( ! empty( $categories ) ) {
  foreach ( $categories as $cat ) {
    $cls .= $cat->slug . ' ';
  }
}
?>
<li class="<?php echo $cls; ?> ">                        
                        


Post Categories