The get_the_excerpt() WordPress function Updated on April 21, 2022 by Jeff Matson 1 Minutes, 6 Seconds to Read 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. If you would like more information on creating WordPress plugins, see our tutorial series on creating your first WordPress plugin. 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. wp_trim_excerpt( string $text = '', WP_Post|object|int $post = null ) For more information on the wp_trim_excerpt() function, take a look at the wp_trim_excerpt() WordPress reference page. References For the full, official documentation on the get_the_excerpt() function, take a look at the get_the_excerpt() WordPress reference page. Share this Article Related Articles How to Create an Admin Account in WordPress via MySQL Create a Footer for WordPress How to Create a Gallery in WordPress without a Plugin How to Disable the WP-Cron (wp-cron.php) in WordPress How to Change Your Site URL in Your WordPress Admin Dashboard W3 Total Cache – Guide to WordPress Caching WordPress – Changing the Site URL and Home Settings How to Globally Change the Font in WordPress How to Install WordPress using Softaculous Cleaning Up Old Post Metadata in WordPress