Function: wp_generate_tag_cloud

wp_generate_tag_cloud( array<mixed,\WP_Term> $tags, string | array $args )

Generates a tag cloud (heatmap) from provided data.

Shortcut: wgtc

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

Parameters

Name Type(s) Default Value Description
$tags array<mixed,WP_Term>

Array of WP_Term objects to generate the tag cloud for.

$args string | array ''

{ Optional. Array or string of arguments for generating a tag cloud.

@type int      $smallest                   Smallest font size used to display tags. Paired
                                           with the value of `$unit`, to determine CSS text
                                           size unit. Default 8 (pt).
@type int      $largest                    Largest font size used to display tags. Paired
                                           with the value of `$unit`, to determine CSS text
                                           size unit. Default 22 (pt).
@type string   $unit                       CSS text size unit to use with the `$smallest`
                                           and `$largest` values. Accepts any valid CSS text
                                           size unit. Default 'pt'.
@type int      $number                     The number of tags to return. Accepts any
                                           positive integer or zero to return all.
                                           Default 0.
@type string   $format                     Format to display the tag cloud in. Accepts 'flat'
                                           (tags separated with spaces), 'list' (tags displayed
                                           in an unordered list), or 'array' (returns an array).
                                           Default 'flat'.
@type string   $separator                  HTML or text to separate the tags. Default "\n" (newline).
@type string   $orderby                    Value to order tags by. Accepts 'name' or 'count'.
                                           Default 'name'. The {@see 'tag_cloud_sort'} filter
                                           can also affect how tags are sorted.
@type string   $order                      How to order the tags. Accepts 'ASC' (ascending),
                                           'DESC' (descending), or 'RAND' (random). Default 'ASC'.
@type int|bool $filter                     Whether to enable filtering of the final output
                                           via {@see 'wp_generate_tag_cloud'}. Default 1|true.
@type string   $topic_count_text           Nooped plural text from _n_noop() to supply to
                                           tag counts. Default null.
@type callable $topic_count_text_callback  Callback used to generate nooped plural text for
                                           tag counts based on the count. Default null.
@type callable $topic_count_scale_callback Callback used to determine the tag count scaling
                                           value. Default default_topic_count_scale().
@type bool|int $show_count                 Whether to display the tag counts. Default 0. Accepts
                                           0, 1, or their bool equivalents.

}

Returns

string | array

Tag cloud as a string or an array, depending on 'format' argument.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.