So I tried the following to print the index of the current post as part of the CSS class names, but $wp_query->current_post returns 0 every time. This is probably because generatepress or generateblocks isn’t use the main query but creating a custom one. Any idea on how to get that the current query?
add_filter( 'render_block', function( $block_content, $block ){
global $wp_query;
$className = 'rr-analytics-home-primary-article';
if ( ! empty( $block['attrs']['className'] ) && $className === $block['attrs']['className'] ) {
return str_replace($className, $className . " " . $wp_query->current_post , $block_content);
}
return $block_content;
}, 10, 2);