Give each excerpt a unique class in WordPress

Giving an excerpt an unique class may come handy when writing CSS in BEM style. Here's a small function to do just that.

This goes into your function.php file:

function cm_excerpt( $class ) {
    $excerpt = strip_tags( get_the_excerpt() );
    echo '<p class="' . $class . '">' . $excerpt . '</p>';
}

Usage:

<?php excerpt('article__excerpt'); ?>

Club-Mate, the beverage → club-mate.fi