一个解决方案是wp_insert_post_data 并执行一些regex魔术来替换& 具有&:
// when saving posts, replace & with &
function cc_wpse_264548_unamp( $data ) {
$data[\'post_content\'] = preg_replace(
"/&/", // find \'&\'
"&", // replace with \'&\'
$data[\'post_content\'] // target the \'post_content\'
);
return $data;
}
add_filter( \'wp_insert_post_data\', \'cc_wpse_264548_unamp\', 20 );
显然,只有在保存/更新帖子时,您才会看到更改。