do_blocks() WordPress Function

The do_blocks() function is used to handle the processing of WordPress blocks. It is responsible for rendering the blocks on the front-end of the site. This function is called by the WordPress core when a post is being displayed.

do_blocks( string $content ) #

Parses dynamic blocks out of post_content and re-renders them.


Parameters

$content

(string)(Required)Post content.


Top ↑

Return

(string) Updated post content.


Top ↑

Source

File: wp-includes/blocks.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
5.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.