0

When copywrighter publish an article, sometimes they forget to add the section Read more, and I have to do it manually. Is there a way to add it automatically in the article ?

Thank you very much.

0

Use the excerpt with a custom read more link in functions.php

add_filter( 'excerpt_length', 'modify_excerpt_length' );

function modify_excerpt_length( $length ) {

    return 15; 
}


add_filter( 'excerpt_more', 'your_excerpt_more' );

function your_excerpt_more( $more ) {

$more = sprintf( ' <a href="%s" class="read-more" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );

return $more;
}

Or, you can filter the_excerpt or get_the_excerpt hook like this :

add_filter( 'get_the_excerpt', 'link_read_more' );

function link_read_more( $output ) {

$more = sprintf( ' <a href="%s" class="read-more" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );

return $output . $more;
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.