How to get the excerpt of post in WordPress

To get the excerpt of a post,we can use get_the_excerpt function.

for example:

<?php
if(has_excerpt()){
$content = get_the_excerpt();
echo $content;
}
?>

Notice: if we do not use has_excerpt() to check, the get_the_excerpt() will return full content of a post if the excerpt is empty.

,