WP_Block_Type::render() WordPress Method

The WP_Block_Type::render() method is used to render a given block type. This is done by running the block type's render_callback() method, if it exists. If the render_callback() method doesn't exist, the method will fall back to rendering the block type's save() method return value.

WP_Block_Type::render( array $attributes = array(), string $content = '' ) #

Renders the block type output for given attributes.


Parameters

$attributes

(array)(Optional) Block attributes.

Default value: array()

$content

(string)(Optional) Block content.

Default value: ''


Top ↑

Return

(string) Rendered block type output.


Top ↑

Source

File: wp-includes/class-wp-block-type.php

	public function render( $attributes = array(), $content = '' ) {
		if ( ! $this->is_dynamic() ) {
			return '';
		}

		$attributes = $this->prepare_attributes_for_render( $attributes );

		return (string) call_user_func( $this->render_callback, $attributes, $content );
	}


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.