Halloween Sale 15% off Ends in See the plans
PHP

Descriptive "Read More" Links With the Post Title

Adds the post title as hidden text to "Read more" and "Continue reading" links, so screen reader users hear where each link goes instead of a list of identical links.

Don’t have WPIDE yet? Install it on your site

Code

// Visible link text; the post title is appended as hidden text.
$wpide_more_text = 'Read more';

$wpide_more_link = function () use ( $wpide_more_text ) {
    return sprintf(
        ' <a class="more-link" href="%1$s">%2$s<span class="screen-reader-text"> about %3$s</span></a>',
        esc_url( get_permalink() ),
        esc_html( $wpide_more_text ),
        esc_html( get_the_title() )
    );
};

add_filter( 'excerpt_more', function () use ( $wpide_more_link ) {
    return '…' . $wpide_more_link();
}, 20 );

add_filter( 'the_content_more_link', function () use ( $wpide_more_link ) {
    return $wpide_more_link();
}, 20 );

Notes

Change $wpide_more_text to the visible wording you want; the post title is added for screen readers only.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.