Site logo

Archived topic

aria-label - matching issue?

3 replies · Started by William on June 29, 2022

Viewing posts 1–4 of 4

Aloha :)

I'm using a 'Dynamic Content block' set to 'Post excerpt' with the 'Use theme more link' selected.

The link text is set to display as "Read more" (in Customizer)

I end up with an aria-label that looks like this for my "Read more" link.

aria-label="More on [post title]"

Is there a way to control the two words "More on"?

My accessibility checker is telling me a better aria-label would be "Read more on"

Thanks for any thoughts you can offer :)

_bill - Hawaii

Hi William,

Yes, there is a way and you can do it by using filter generate_excerpt_more_output.

Reference: https://docs.generatepress.com/article/generate_excerpt_more_output/

For instance, here’s a snippet you may try:

add_filter('generate_excerpt_more_output', function(){
	$new_more = sprintf(
				' ... <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
				the_title_attribute( 'echo=0' ),
				esc_url( get_permalink( get_the_ID() ) ),
				__( 'Read more', 'generatepress' ),
				sprintf(
					/* translators: Aria-label describing the read more button */
					_x( 'Read more on %s', 'more on post title', 'generatepress' ),
					the_title_attribute( 'echo=0' )
				)
			);
	return $new_more;
});

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Hope this helps! Kindly let us know how it goes.

Amazing as always :)

You are all indeed ... THE BEST.

With much aloha from Hawaiʻi.

_bill

You’re welcome Bill! Aloha!

This archived topic is closed to new replies.