Adding the_excerpt in WP

by

How to add auto excerpts to a WP Theme:

For this example, I’m using the WP Bootstrap Starter theme (remember to create a Child theme, or you will lose any edits after you update). You need to locate content.php file, it should be under the template-parts folder:

Find the code:
the_content( __( 'Continue reading ', 'wp-bootstrap-starter' ) );

Approx. line 33.

Replace with:
the_excerpt();

Then in the functions.php file, add:

function custom_excerpt_length( $length ) {
return 55;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

You can replace ’55’ with whichever # you want.

Here is the code to update the Read More text:

function custom_excerpt_more( $more ) {
return '... Read More';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );

If you run into any problems, check your read more settings:

WP >> Settings >> Reading >> “Summary”

read more settings wp

Leave a Reply

Your email address will not be published. Required fields are marked *


PageLines