WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/17/2020 06:19:48 PM (12 months ago)
Author:
SergeyBiryukov
Message:

Twenty Nineteen: Add "Continue reading" link for post excerpts.

This ensures that archive pages have a meaningful link text after the excerpts.

Props metalandcoffee, alex27, sabernhardt, mdrockwell, laurelfulford.
Fixes #46177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentynineteen/functions.php

    r49348 r49831  
    206206
    207207/**
     208 * Replaces "[...]" (appended to automatically generated excerpts) with ... and
     209 * a 'Continue reading' link.
     210 *
     211 * @since Twenty Nineteen 2.6
     212 *
     213 * @param string $link Link to single post/page.
     214 * @return string 'Continue reading' link prepended with an ellipsis.
     215 */
     216function twentynineteen_excerpt_more( $link ) {
     217    if ( is_admin() ) {
     218        return $link;
     219    }
     220
     221    $link = sprintf(
     222        '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
     223        esc_url( get_permalink( get_the_ID() ) ),
     224        /* translators: %s: Post title. */
     225        sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentynineteen' ), get_the_title( get_the_ID() ) )
     226    );
     227    return ' &hellip; ' . $link;
     228}
     229add_filter( 'excerpt_more', 'twentynineteen_excerpt_more' );
     230
     231/**
    208232 * Set the content width in pixels, based on the theme's design and stylesheet.
    209233 *
Note: See TracChangeset for help on using the changeset viewer.