wpseek.com
A WordPress-centric search engine for devs and theme authors



render_block_core_post_comments_count › WordPress Function

Since6.9.0
Deprecatedn/a
render_block_core_post_comments_count ( $attributes, $content, $block )
Parameters: (3)
  • (array) $attributes Block attributes.
    Required: Yes
  • (string) $content Block default content.
    Required: Yes
  • (WP_Block) $block Block instance.
    Required: Yes
Returns:
  • (string) Returns the filtered post comments count for the current post.
Defined at:
Codex:

Renders the `core/post-comments-count` block on the server.



Source

function render_block_core_post_comments_count( $attributes, $content, $block ) {
	if ( ! isset( $block->context['postId'] ) ) {
		return '';
	}

	$classes = '';
	if ( isset( $attributes['textAlign'] ) ) {
		$classes .= 'has-text-align-' . $attributes['textAlign'];
	}

	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
	return sprintf(
		'<div %1$s>%2$s</div>',
		$wrapper_attributes,
		get_comments_number( $block->context['postId'] )
	);
}