WordPress tag cloud tag: WP_ tag_ cloud

WordPress template tags WP_ tag_ Cloud is used to output tag cloud, and the size of tag is determined by the number of articles under the tag.

wp_tag_cloud( array $args = '' )

Function parameters$args

Array or string value

wp_ tag_ The default value of the $args parameter of the cloud() function is as follows:

$args = array(
	'smallest'                  => 8, 
	'largest'                   => 22,
	'unit'                      => 'pt', 
	'number'                    => 45,  
	'format'                    => 'flat',
	'separator'                 => "n",
	'orderby'                   => 'name', 
	'order'                     => 'ASC',
	'exclude'                   => null, 
	'include'                   => null, 
	'topic_count_text_callback' => default_topic_count_text,
	'link'                      => 'view', 
	'taxonomy'                  => 'post_tag', 
	'echo'                      => true,
	'child_of'                  => null,
);

wp_ tag_ The available values of the $args parameter of the cloud() function are as follows:

smallest

Integer type, default value: 8

Minimum font size

largest

Integer type, default value: 22

Maximum font size

unit

String value, default value: Pt

Name unit

number

Integer type, default value: 45

Number of tags displayed

format

String value, default value: flat

List format, optional values:

  • Flat: space
  • List: UL list
  • Array: array

separator

String value, default value:

Text between tags

orderby

String value, default value: name

Collation, optional values:

  • Name: sort by name
  • Count: sort by the number of articles

order

String value, default value: ASC

Sorting method, optional value:

  • ASC: ascending order
  • Desc: descending order
  • Rand: random

exclude

String value, default value: null

Provide tag IDs to exclude the display of these tags. Multiple tag IDs are separated by half width commas

include

String value, default value: null

Provide tag IDs to display the tags. Multiple tag IDs are separated by half width commas

topic_ count_ text_ callback

String value, default value: default_ topic_ count_ text

Specify a function name. The value returned by the function will be used as the title property value of the link. The default output is the number of articles. For example, 28 topics

link

String value, default value: View

Type of link, optional value:

  • View: output label archive page link
  • Edit: when you are logged in and have the permission to edit the tag, output the link to edit the tag, otherwise output the link to the home page

taxonomy

String or array, default value: Post_ tag

Specify the taxonomy name, optional value:

  • post_ Tag: article tag
  • Category: article classification
  • link_ Category: friendship link classification

echo

Boolean value, default value: true

Output return result

Examples of function usage

<?php if ( function_exists( 'wp_tag_cloud' ) ) : ?>
	<h2>标签云集</h2>
	<ul>
		<li><?php wp_tag_cloud( 'smallest=8&largest=22' ); ?></li>
	</ul>
<?php endif; ?>

Extended reading

wp_ tag_ The cloud() function is located in: WP includes / category- template.php

Related tags:

  • get_ tag()
  • get_ tag_ link()
  • get_ tags()
  • get_ the_ tag_ list()
  • get_ the_ tags()
  • is_ tag()
  • the_ tags()
  • single_ tag_ title()
  • tag_ description()
  • wp_ generate_ tag_ cloud()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image