wppaste
WordPress

the_content_rss( string $more_link_text = '(more...)', int $stripteaser = 0, string $more_file = '', int $cut = 0, int $encode_html = 0 )

Since
0.71
Source
wp-includes/deprecated.php:1683
Display the post content for the feed.

Description

For encoding the HTML or the $encode_html parameter, there are three possible values:

  • '0' will make urls footnotes and use make_url_footnote().
  • '1' will encode special characters and automatically display all of the content.
  • '2' will strip all HTML tags from the content.

Also note that you cannot set the amount of words and not set the HTML encoding.
If that is the case, then the HTML encoding will default to 2, which will strip all HTML tags.

To restrict the amount of words of the content, you can use the cut parameter.
If the content is less than the amount, then there won't be any dots added to the end.
If there is content left over, then dots will be added and the rest of the content will be removed.

Compatibility

Deprecated in WordPress 2.9.0. Use the_content_feed()

WordPress
since 0.71
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$stripteaserintoptional
Default 0.Default: 0
$more_filestringoptional
Default: ''
$cutintoptional
Amount of words to keep for the content.Default: 0
$encode_htmlintoptional
How to encode the content.Default: 0

Performance profile

How much work a call to the_content_rss() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
33–59

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 77.

Plugin surface
1 hook

Third-party callbacks on 'the_content_rss' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()one call below the_content_rss()
  • optionoption read or writeget_option()one call below the_content_rss()

Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 8 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost the_content_rss() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$encode_html != 1 && $encode_html != 0 && $encode_html != 233–35_deprecated_function(), get_the_content(), apply_filters()
$encode_html == 135–37_deprecated_function(), get_the_content(), apply_filters(), esc_html()
$encode_html != 1 && $encode_html == 036–38_deprecated_function(), get_the_content(), apply_filters(), make_url_footnote()
$encode_html != 1 && $encode_html != 0 && $encode_html == 237–39_deprecated_function(), get_the_content(), apply_filters(), strip_tags()
$encode_html != 1 && $encode_html != 0 && $encode_html != 2 && !$i51–55_deprecated_function(), get_the_content(), apply_filters(), explode()
$encode_html == 1 && !$i53–57_deprecated_function(), get_the_content(), apply_filters(), esc_html(), explode()
$encode_html != 1 && $encode_html == 0 && !$i54–58_deprecated_function(), get_the_content(), apply_filters(), make_url_footnote(), explode()
$encode_html != 1 && $encode_html != 0 && $encode_html == 2 && !$i55–59_deprecated_function(), get_the_content(), apply_filters(), strip_tags(), explode()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev7733–599
8.57733–599
8.47733–5993 fewer instructions than PHP 8.3
8.38036–629
8.28036–629
8.18036–629
7.48036–629

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while the_content_rss() runs, in this order:

  1. apply_filters( the_content_rss )filterline 1694 (+11 into the body)

    Filters the post content in the context of an RSS feed.

Uses · 5

Source code

function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {	_deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' );	$content = get_the_content($more_link_text, $stripteaser); 	/**	 * Filters the post content in the context of an RSS feed.	 *	 * @since 0.71	 *	 * @param string $content Content of the current post.	 */	$content = apply_filters('the_content_rss', $content);	if ( $cut && !$encode_html )		$encode_html = 2;	if ( 1== $encode_html ) {		$content = esc_html($content);		$cut = 0;	} elseif ( 0 == $encode_html ) {		$content = make_url_footnote($content);	} elseif ( 2 == $encode_html ) {		$content = strip_tags($content);	}	if ( $cut ) {		$blah = explode(' ', $content);		if ( count($blah) > $cut ) {			$k = $cut;			$use_dotdotdot = 1;		} else {			$k = count($blah);			$use_dotdotdot = 0;		} 		/** @todo Check performance, might be faster to use array slice instead. */		for ( $i=0; $i<$k; $i++ )			$excerpt .= $blah[$i].' ';		$excerpt .= ($use_dotdotdot) ? '...' : '';		$content = $excerpt;	}	$content = str_replace(']]>', ']]&gt;', $content);	echo $content;}

Changelog

Introduced in 0.71. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

2.9.0
Deprecated. Use the_content_feed()from the docblock
0.71
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/deprecated.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.