您可以筛选the_content
和使用preg_replace()
查找的实例<table></table>
然后用你的<div>
.
add_action( \'the_content\', \'wpse_260756_the_content\', 10, 1 );
function wpse_260756_the_content( $content ) {
$pattern = "/<table(.*?)>(.*?)<\\/table>/i";
$replacement = \'<div class="table-responsive"><table$1>$2</table></div>\';
return preg_replace( $pattern, $replacement, $content );
}