Built within WordPress, is the ability to add excerpts to your posts. Of course, these excerpts will not do you any good if you cannot display them on your WordPress site. In this article, we will show you the get_the_excerpt() function that you can use within your themes or plugins to display the post excerpt.

Basic usage

<?php $excerpt = get_the_excerpt() ?>

In this example, we simply get the excerpt using the get_the_excerpt() function, and assign it to the $excerpt variable.

Now that the variable contains the excerpt of the post, we can now display it like this:

<?php echo $excerpt; ?>

What if I don't have an excerpt defined?

If an excerpt is not defined within the post, the wp_trim_excerpt() function will be used on the post content so that an excerpt is still displayed.

For more information on the wp_trim_excerpt() function, take a look at the wp_trim_excerpt() WordPress Codex page.

References

For the full, official documentation on the get_the_excerpt() function, take a look at the get_the_excerpt() WordPress Codex page.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!