Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

34 PART I • Getting Started with WordPress


FUNCTION AND QUERY-STRING STYLE ARGUMENTS
Now look at something a bit more complicated:

<?php wp_tag_cloud(); ?>

This template tag will output a tag cloud displaying at most 45 tags, with the smallest one at
the font size of 8 pt (points), and the largest at 22 pt. They are displayed in a flat listing and
sorted by name, in ascending order. You know this because these are the default values, and
there are a lot of them, as you can see in Table 2-1. In fact, wp_tag_cloud() can pass 14
arguments to a parameter.

Table 2-1 Default Tag-Cloud Parameters


Parameter Description Default Value

smallest Smallest tag size 8
largest Largest tag size 22
unit What font size unit is used pt
number How many tags to display at most 45
format How to display the tags flat
separator What goes between the tags whitespace
orderby How to order the tags name
order How to sort the tags ASC
exclude What tags to exclude none
include What tags to include all
link Should links be edit or view view
taxonomy The basis for the tag cloud post_tag
topic_count_text_
callback

Lets you create a custom tooltip
for links

default_topic_count_
text
echo Whether to show the tag cloud or
return it

true

If you compare these values to the description of the default output of wp_tag_cloud(),
you’ll see that they are passed without your needing to pass any arguments manually.

Now try altering the tag by changing some arguments within this parameter. There are two
ways to pass arguments to the wp_tag_cloud() parameter: function or query-string style.
If you’ve been using WordPress for a while, you have no doubt seen them both. Function style
is the preferred method today, but you’ll run into query-string style as well.
Free download pdf