filter

jetpack_relatedposts_filter_post_css_classes

Filter the post css classes added on HTML markup.

Parameters

$post_id
string

Post ID.

array()
array

CSS classes added on post HTML markup.

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

You could use this filter to add each post’s category slugs to the container’s class, like so:
function add_css_classes_on_related_posts( $classes, $post_id ) {
	$categories = get_the_category( $post_id );

	foreach ( $categories as $category ) {
		$classes[] = 'category-' . $category->slug;
	}

	return $classes;
}

add_filter('jetpack_relatedposts_filter_post_css_classes', 'add_css_classes_on_related_posts', 10, 2);
That can be helpful when one wants to style Related Posts differently depending on the post’s category, for example.