Site logo

Archived topic

Need a Line Break Before Read More on Custom Excerpts

1 reply · Started by catbiscuits on July 26, 2022

Viewing posts 1–2 of 2

I have successfully followed your instructions on how to show the Read More button on my blog page when I am using Custom Excerpts, but the Read More text runs into the Excerpt now (http://npsnj.org/news). How can I add a line break to the snippet to put it on a separate line?

Hi Catbiscuits,

You can try altering your PHP into something like this:

add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
    $output = $excerpt;	
    if ( has_excerpt() ) {
        $output = sprintf( '%1$s <br><a href="%2$s">%3$s</a>',
            $excerpt,
            get_permalink(),
            __( 'Read more', 'generatepress' )
        );
    }

    return $output;
}

I added a <br> within the code.

Hope this helps.

This archived topic is closed to new replies.