The WordPress Excerpt is an optional summary or description of a post; in short, a post’s summary.
The Excerpt has two main uses: (WordPress Excerpt)
- It replaces the full content in RSS feeds when the option to display summaries is selected in Dashboard › Settings › Reading.
- Depending on the WordPress theme, it can be displayed in places where quick summaries are preferable to full content:
* Search results
* Tag archives
* Category archives
* Monthly archives
* Author archives
How To Add Excerpts To Posts
To add an excerpt to a post, simply write one in the Excerpt field under the post edit box. An excerpt can be as short or as long as you wish. Usually, given its purpose, a couple of sentences is fine.
Interestingly, since the WordPress excerpt is similar in purpose to the META description of (X)HTML documents, excerpts can additionally be used as meta descriptions too. Some themes do this by default. It can also be done by means of an SEO plugin or a plugin for managing data in the head of (X)HTML pages.
Since the_excerpt() prints directly to the screen and can’t be passed to other PHP functions, you can’t wrap it in the esc_attr() function, as you normally would when using a template tag as an HTML attribute. Instead, you use the_excerpt_rss(). This function formats the excerpt for RSS feeds, but in this case, it will work equally well in your description attribute since excerpts can’t contain HTML.
Add this lines code between the <head></head> tags in the header.php file of your WordPress theme, which display the excerpt as the meta description tag for single posts and pages.
<?php if (is_singular()): global $post; setup_postdata($post); ?> <meta name="description" content="<?php the_excerpt_rss(); ?>" /> <?php endif; ?>
I have not discussed The WordPress Excerpt in detail but rather explained most important part. I tried to make some sense of it by focusing on what seemed essential to me and without going into too much detail. If you think there is still too much detail, or not enough detail, leave a comment to say so. If you are still satisfied read the following reference and I hope you will find WordPress Excerpt in detail.