wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



render_block_core_post_comments_count › WordPress Function

Seit6.9.0
Veraltetn/v
render_block_core_post_comments_count ( $attributes, $content, $block )
Parameter: (3)
  • (array) $attributes Block attributes.
    Erforderlich: Ja
  • (string) $content Block default content.
    Erforderlich: Ja
  • (WP_Block) $block Block instance.
    Erforderlich: Ja
Gibt zurück:
  • (string) Returns the filtered post comments count for the current post.
Definiert in:
Codex:

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



Quellcode

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'] )
	);
}