Excerpt

Home » Excerpt

An excerpt in WordPress is a term used for displaying a snippet of text from an article or page on another page of your website. You can see an example of excerpts in use on our blog page. Each of the articles shows a preview or excerpt of the full text for that post.

WordPress Excerpt Example
An example of the excerpt in play on the WP Absolute blog.

An excerpt is an optional feature in WordPress and is used on a per theme basis. It allows you display snippets of content without taking up the space of displaying the entire content.

An excerpt is most commonly displayed on dynamic and content rich websites like news or magazine style websites. It is common for these types of websites to display these snippets across different parts of the site. Especially on the homepage.

Excerpts are not limited to dynamic content though. They are also displayed in other areas across the site too. You will find an excerpt on your search results pages, utilized in RSS feeds as well as on archive pages.

There are a number of ways to control the excerpt.

The Excerpt Box
If your theme uses WordPress excerpts then you will be able to see an excerpt box on the post editor page where you can explicitly type an excerpt.

If you cannot see the excerpt box underneath the editor on the post edit screen then you can enable it by selecting the screen options drop-down in the upper right hand corner and making sure excerpt is enabled.

Manual Excerpt Box
The Manual Excerpt Box is located underneath the main content in the post editor page. You can enable it in the screen options drop-down tab.

The More Tag
Another way to control the excerpt is by setting the length of the excerpt using the <!–more–> tag. There is a button on both the visual editor and the text editor to insert a more tag. To insert it, position your cursor where you want the excerpt to finish and then click the more button in the toolbar to insert it.

Insert Read More Tag WordPress Excerpt
The Insert Read More tag can be inserted in both visual and text modes using the insert buttons.

The Automated Excerpt
If you do not explicitly set the excerpt then WordPress may automatically generate it from the main content of that post if it needs to display an excerpt.

By default, an excerpt will be automatically created from the first 55 words of the article. The excerpt length and appearance can be modified. This is an example of modifying the excerpt displayed to show a “… Continue Reading” link after the content rather than the default […]. Paste the following code into your child themes functions.php file to modify the excerpt output.

/*******************************************************************************
WP Absolute Post excerpt continue reading link
*******************************************************************************/
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link.
*
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function wpabsolute_excerpt_more( $more ) {
if ( is_admin() ) {
return;
}

$link = sprintf( '
<p class="link-more"><a class="more-link" href="%1$s">%2$s</a></p>
',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue Reading %s', 'textdomain' ),
'<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>'
)
);
return '  ' . $link;
}
add_filter( 'excerpt_more', 'wpabsolute_excerpt_more' );

You can also set the length of the excerpt with another filter. Paste the following code into your child themes functions.php file to modify the length of the excerpt.

/*******************************************************************************
Set the automatically generated excerpts length
*******************************************************************************/
function wpabsolute_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'wpabsolute_excerpt_length' );

In the function above, we set the excerpt length to 40 however you can modify the length however you long you want. Just replace the 40 with another number.

Posted on