anonymized-13171256
(@anonymized-13171256)
Great idea!
Add this to your theme’s functions.php or create an mu-plugin.
/**
* Add category to testimonial CSS classes.
*
* For Strong Testimonials.
*/
function my_testimonial_class( $classes, $args ) {
global $post;
$class_list = explode( ' ', $classes );
$categories = wp_get_object_terms( $post->ID, 'wpm-testimonial-category' );
if ( ! empty( $categories) && ! is_wp_error( $categories ) ) {
foreach ( $categories as $category ) {
// To add the ID:
$class_list[] = 'category-' . $category->term_id;
// To add the slug:
$class_list[] = 'category-' . $category->slug;
}
}
$classes = implode( ' ', array_unique( $class_list ) );
return $classes;
}
add_filter( 'wpmtst_post_class', 'my_testimonial_class', 10, 2 );
Example CSS:
.strong-view .testimonial.category-1 {
border: 1px solid red;
}
or
.strong-view .testimonial.category-my-product {
border: 1px solid red;
}
You may need to increase the specificity by adding the template name:
.strong-view.default .testimonial.category-2 {
border: 1px solid red;
}
Thank you, this is just what I needed! If you ever get around to it, adding this to the UI of the plugin would probably be well received!