We can try these steps:
1. Add an additional CSS class to the container block, eg. add-title-aria-label
.
Adding CSS class(es): https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
2. Add title
as the aria label:
https://www.screencast.com/t/JFuclCwcfmv
3. Add this PHP snippet to replace the static title
text with dynamic post title:
function add_title_aria_label( $block_content, $block ) {
if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'add-title-aria-label' ) !== false ) {
$post_title = get_the_title(get_the_ID());
$my_search='aria-label="title';
$my_replace='aria-label="'.$post_title;
$new_content = str_replace($my_search, $my_replace, $block_content);
return $new_content;
}
return $block_content;
}
add_filter( 'render_block', 'add_title_aria_label', 10, 2 );
Adding PHP: https://docs.generatepress.com/article/adding-php/