• Resolved Karis

    (@askel45)


    Hi @edge22. I saw the Read more link outputs a ‘title’ instead of an ‘aria-label’. Is there a preference you have for the former over the latter?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Theme Author Tom

    (@edge22)

    It should actually add an aria-label as well as a title: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/post-meta.php#L453

    Is that not happening for you?

    Thread Starter Karis

    (@askel45)

    I was given this code by David to change the read more text while retaining the HTML markup of the button (for screen readers). So only the title is showing.

    add_filter( 'generate_excerpt_more_output', function() {
          return sprintf( ' ... <a class="read-more button" title="%1$s" href="%2$s">%3$s</a>',
    	the_title_attribute( 'echo=0' ),
    	esc_url( get_permalink( get_the_ID() ) ),
    	__( 'Continue Reading', 'generatepress' )
    );
    });

    NB: Adding aria-label="%4$s"> makes the button to disappear.

    More: Does this filter need to be updated? https://docs.generatepress.com/article/generate_excerpt_more_output/

    Thread Starter Karis

    (@askel45)

    Additional question. Is there a way to just change the read more text with a return ''; filter?

    Change your filter snippet to this:

    add_filter( 'generate_excerpt_more_output', function() {
      return 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() ) ),
        __( 'Continue Reading', 'generatepress' ),
        sprintf(
          /* translators: Aria-label describing the read more button */
          _x( 'Continue Reading on %s', 'more on post title', 'generatepress' ),
          the_title_attribute( 'echo=0' )
        )
      );
    });
    Thread Starter Karis

    (@askel45)

    That does the trick! Thanks. The former code and its output were confusing some screen reader extensions which were only reading the “continue reading” text instead of also including the title.

    Does this mean the filter code also needs to be updated?

    Yeah the doc is on our list of to dos – the Read More was updated in 3.0 to add the Aria – so we’re slowly working through each doc as we see more users move to 3.0.

    Glad to be of help

    • This reply was modified 5 years, 7 months ago by David.
    Leo

    (@leohsiang)

    Doc page updated 🙂

    Thread Starter Karis

    (@askel45)

    @leohsiang always to the rescue. Hahaa.

    Leo

    (@leohsiang)

    Appreciate your QA help 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Read More link’ is closed to new replies.