@morgan提出了很好的解决方案,但我认为最好add_filter 在else中,下一个块或内容将使用WPAUTOP进行筛选
/**
* Try to disable wpautop inside specific blocks.
*
* @link https://wordpress.stackexchange.com/q/321662/26317
*
* @param string $block_content The HTML generated for the block.
* @param array $block The block.
*/
add_filter( \'render_block\', function ( $block_content, $block ) {
if ( \'acf/featured-pages\' === $block[\'blockName\'] ) {
remove_filter( \'the_content\', \'wpautop\' );
} elseif ( ! has_filter( \'the_content\', \'wpautop\' ) ) {
add_filter( \'the_content\', \'wpautop\' );
}
return $block_content;
}, 10, 2 );