do_blocks

函数
do_blocks ( $content )
参数
  • (string) $content Post content.
    Required:
返回值
  • (string) Updated post content.
定义位置
相关方法
has_blocksrender_blockparse_blockshas_blockdo_trackbacks
引入
5.0.0
弃用
-

do_blocks: 这个钩子用来渲染文章编辑器的内容,包括经典编辑器和块编辑器。

分析“post_content”中的动态区块并重新渲染它们。

function do_blocks( $content ) {
	$blocks = parse_blocks( $content );
	$output = '';

	foreach ( $blocks as $block ) {
		$output .= render_block( $block );
	}

	// If there are blocks in this content, we shouldn't run wpautop() on it later.
	$priority = has_filter( 'the_content', 'wpautop' );
	if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) {
		remove_filter( 'the_content', 'wpautop', $priority );
		add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 );
	}

	return $output;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-06 12:33:18

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: