I’m pretty sure this is already coded in on my base theme template?
This code goes in the main functions.php file (not the child theme)
function new_excerpt_more( $more ) {
return '... <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('~ keep reading ~', 'your-text-domain') . '</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
//Filter the except length to 20 characters.
function wpdocs_custom_excerpt_length( $length ) {
return 50;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
This code goes in theme > child theme >template parts > content.php
Search for the lines:
<div class=“entry-content”> <?php
Add the following code snippet just below them:
if ( is_home() || is_category()||is_archive()){ the_excerpt(''); }else{
Find the statements:
?> </div><!-- .entry content -->
Then insert the following line above them:
} // end of if statements