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
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
$more_link_textstringoptional- Text to display when more content is available but not displayed. Default '(more...)'.Default:
'(more...)' $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
- Scaling
- Scales with input
- Instructions
- 33–59
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_post().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 77.
Third-party callbacks on 'the_content_rss' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - querycontent query
get_post()one call below the_content_rss() - optionoption read or write
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
$encode_html != 1 && $encode_html != 0 && $encode_html != 2 | 33–35 | _deprecated_function(), get_the_content(), apply_filters() |
$encode_html == 1 | 35–37 | _deprecated_function(), get_the_content(), apply_filters(), esc_html() |
$encode_html != 1 && $encode_html == 0 | 36–38 | _deprecated_function(), get_the_content(), apply_filters(), make_url_footnote() |
$encode_html != 1 && $encode_html != 0 && $encode_html == 2 | 37–39 | _deprecated_function(), get_the_content(), apply_filters(), strip_tags() |
$encode_html != 1 && $encode_html != 0 && $encode_html != 2 && !$i | 51–55 | _deprecated_function(), get_the_content(), apply_filters(), explode() |
$encode_html == 1 && !$i | 53–57 | _deprecated_function(), get_the_content(), apply_filters(), esc_html(), explode() |
$encode_html != 1 && $encode_html == 0 && !$i | 54–58 | _deprecated_function(), get_the_content(), apply_filters(), make_url_footnote(), explode() |
$encode_html != 1 && $encode_html != 0 && $encode_html == 2 && !$i | 55–59 | _deprecated_function(), get_the_content(), apply_filters(), strip_tags(), explode() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 77 | 33–59 | 9 | |
| 8.5 | 77 | 33–59 | 9 | |
| 8.4 | 77 | 33–59 | 9 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 80 | 36–62 | 9 | |
| 8.2 | 80 | 36–62 | 9 | |
| 8.1 | 80 | 36–62 | 9 | |
| 7.4 | 80 | 36–62 | 9 |
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:
- apply_filters( the_content_rss )filterline 1694 (+11 into the body)
Filters the post content in the context of an RSS feed.
Uses · 5
- _deprecated_function()Marks a function as deprecated and inform when it has been used.
- get_the_content()Retrieves the post content.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_html()Escaping for HTML blocks.
- make_url_footnote()Strip HTML and put links at the bottom of stripped content.
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(']]>', ']]>', $content); echo $content;}Changelog
Introduced in 0.71. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
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.