对于任何寻求此问题解决方案的人,我都会这样做:
function delete_between($beginning, $end, $string) {
$beginningPos = strpos($string, $beginning);
$endPos = strpos($string, $end);
if (!$beginningPos || !$endPos) {
return $string;
}
$textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);
return str_replace($textToDelete, \'\', $string);
}
function clean_content( $content ){
if( is_home() || is_single()){
$content = delete_between(\'<!--[if gte mso\', \';}\', $content);
return $content;
}else{
return $content;
}
add_filter( \'the_content\', \'clean_content\' );
add_filter( \'the_excerpt\', \'clean_content\' );
您可以用所需的任何内容替换delete\\u between函数中的字符串。但这似乎对我有用。