the_content
loop-contentFilters post content before display
the_content is the last chance to change post HTML before it reaches the template. Always return the string — filters that echo will break the page.
Signature
apply_filters( 'the_content', string $content );Example
add_filter( 'the_content', function( $content ) {
if ( is_single() ) {
$content .= '<p><strong>Thanks for reading!</strong></p>';
}
return $content;
} );Common Use Cases
- Append/prepend content to posts
- Transform shortcodes manually
- Add schema markup to content
- Strip or sanitize specific HTML