Source file: modules/related-posts/jetpack-related-posts.php
View in GitHubParameters
- array()
-
(array) array() CSS classes added on post HTML markup.
- $post_id
-
(string) Post ID.
Changelog
Since: Jetpack 3.8.0
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.