According to this link…
https://developer.wordpress.org/reference/functions/post_class/#Add_Classes_By_Filters
…i can add a filter to change the class(es) of a post. How can I do this from a theme? I just have the functions.php and adding this code there doesnt change anything. currently my single posts look like this:
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<div class="wp-block-group has-light-color-background-color has-background is-layout-constrained wp-container-core-group-is-layout-7 wp-block-group-is-layout-constrained">
(content of a single post)
</div>
</div>
I'd like my child-theme to add a class to one of those divs. But adding the linked filter-code to the functions.php doesnt do anything.
I added this code to the functions.php to no avail:
function rewrite_post_class( $classes, $class, $post_id ) {
$classes[] = 'my-custom-class';
return $classes;
}
add_filter( 'post_class', 'rewrite_post_class', 10, 3 );