the_excerpt_rss()WP 0.71

Displays a brief description of the post (quote) or the first 55 words of the content. Used within the WordPress Loop.

The function outputs the value of the "Quote" field (short description); if the short description for the post is not specified, the function will output the first 55 words of the content.

The function applies the hook-filter 'the_excerpt_rss' to the obtained text to modify the output of the text from plugins.

1 time — 0.000652 sec (slow) | 50000 times — 1.71 sec (fast) | PHP 7.1.2, WP 4.7.3
Hooks from the function

Returns

null. Displays a brief description of the post.

Usage

<?php the_excerpt_rss(); ?>

Examples

0

#1 Layout for RSS feeds

Print the post excerpt or the first 55 words of the post content. Wrap the resulting text in a <description> tag for use in the RSS feed:

<description><?php the_excerpt_rss(); ?></description>
0

#2 Short & full content for feed

To create a custom feed that accepts a GET parameter in the URL (for example, http://www.example.com/?feed=myfeed&type=excerpt), place something like the following in your specific feed file to send the excerpt (the_excerpt_rss()) instead of the full content (the_content()):

if ( isset( $_GET['type'] ) ) {
	$typewanted = sanitize_text_field( $_GET['type'] );
}

// excerpt
if ( $typewanted === 'excerpt' ) {
	echo '<span class="excerpt">'; 
		the_excerpt_rss();   
	echo '</span>';
}
// full content
else {  
	echo '<span class="content">';
		the_content();
	echo '</span>';
}

Changelog

Since 0.71 Introduced.

the_excerpt_rss() code WP 6.9

function the_excerpt_rss() {
	$output = get_the_excerpt();
	/**
	 * Filters the post excerpt for a feed.
	 *
	 * @since 1.2.0
	 *
	 * @param string $output The current post excerpt.
	 */
	echo apply_filters( 'the_excerpt_rss', $output );
}