Codex

Function Reference/get the excerpt

Contents

Description

Retrieves the post excerpt.
the_excerpt() function outputs the value returned by get_the_excerpt().

Usage

<?php get_the_excerpt( $deprecated ) ?>

Parameters

$deprecated is not required.

Return Values

  • If the post hasn't got an excerpt, it returns an empty string.
  • For password protected pages it returns a string, which has a default value of "There is no excerpt because this is a protected post." This text can be changed in the function definition.
  • If the post has an excerpt and is not password protected, it returns the excerpt as a string.

Examples

get_the_excerpt() can be used to retrieve and store the value in a variable, without outputting it to the page.

<?php
$myExcerpt = get_the_excerpt();
if ($myExcerpt != '') {
    // Some string manipulation performed
}
echo $myExcerpt; // Outputs the processed value to the page
?>

Source File

get_the_excerpt() is located in wp-includes/post-template.php.

Related

See also index of Function Reference and index of Template Tags.