WordPress开发者和主题制作者的搜索引擎



render_block_core_tag_cloud ›

Sincen/a
已弃用n/a
render_block_core_tag_cloud ( $attributes )
参数:
  • (array) $attributes The block attributes.
    Required: Yes
返回:
  • (string) Returns the tag cloud for selected taxonomy.
定义在:
文档:

Renders the `core/tag-cloud` block on server.



源码

function render_block_core_tag_cloud( $attributes ) {
	$class = isset( $attributes['align'] ) ?
		"wp-block-tag-cloud align{$attributes['align']}" :
		'wp-block-tag-cloud';

	if ( isset( $attributes['className'] ) ) {
		$class .= ' ' . $attributes['className'];
	}

	$args = array(
		'echo'       => false,
		'taxonomy'   => $attributes['taxonomy'],
		'show_count' => $attributes['showTagCounts'],
	);

	$tag_cloud = wp_tag_cloud( $args );

	if ( ! $tag_cloud ) {
		$tag_cloud = esc_html( __( 'No terms to show.' ) );
	}

	return sprintf(
		'<p class="%1$s">%2$s</p>',
		esc_attr( $class ),
		$tag_cloud
	);
}