Add a filter to the_content
并将代码放在其中,这样就不需要自定义内容函数:
function wpa_content_filter( $content ) {
// run your code on $content and
return $content;
}
add_filter( \'the_content\', \'wpa_content_filter\' );
您可能需要调整优先级,以便在其他筛选器之前或之后运行筛选器:
// high priority, run early
add_filter( \'the_content\', \'wpa_content_filter\' 1 );
// low priority, run late
add_filter( \'the_content\', \'wpa_content_filter\' 999 );