Is it possible to change the contents of “the_content()”?

Add a filter to the_content and put your code in there so you don’t need your custom content function:

function wpa_content_filter( $content ) {
    // run your code on $content and
    return $content;
}
add_filter( 'the_content', 'wpa_content_filter' );

You may need to adjust priority to run your filter before or after others:

// high priority, run early
add_filter( 'the_content', 'wpa_content_filter' 1 );

// low priority, run late
add_filter( 'the_content', 'wpa_content_filter' 999 );

Leave a Comment