Wordpress displays posts as a cloud. Tag Cloud Widget in WordPress


Displays or receives a label cloud (a list of labels in the form of a cloud). You can specify a custom taxonomy.

To display elements of a custom taxonomy as a cloud, specify the name of the taxonomy in the taxonomy parameter.

A "label cloud" is called this because the size of each label's text depends on how many entries are associated with the label. The more entries, the larger the label text will be (resulting in something similar to a cloud).

Since version 2.8 the parameter has been added taxonomy, which allows you to create a cloud not only for standard tags, but also for categories and custom taxonomies.

Returns

null. Displays the html code of the list.

  • Returns HTML if echo = false .
  • Returns a label cloud array if format = array .
  • false if the labels could not be retrieved.

Usage pattern

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

Usage

$args (string/array) Arguments on the basis of which the list will be built.
Default: Basic values

$args Parameter Arguments

$args can also be used to specify all the parameters of the get_terms() function. Retrieving taxonomy elements works based on this function.

Smallest (number) Text size for labels with smaller
Default: 8 largest (number) Text size for labels with big number of records (units of measurement are specified in the unit parameter).
Default: unit (line) Parameter units smallest And largest. Can be any CSS size type: pt, px, em, %.
Default: "pt" number (number) The maximum number of tags that will be shown in the list. If set to 0, all labels will be shown without limitation.
Default: 45 format (line)

In what format should the list be displayed? May be:

  • flat - labels will be separated by the separator specified in the parameter separator;
  • list - UL list with CSS class "wp-tag-cloud";
  • array - will return a cloud of labels in an array for further processing in PHP.
    Default: "flat"
separator (line) Text between labels.
Default: "\n" orderby (line) Sort tags by name (name) or number of entries (count). Does not affect the database query.
Default: "name" order (line)

Sorting order. May be:

  • ASC - in order (1,2,3);
  • DESC - in reverse order (3,2,1);
  • RAND - chaotic order (shuffle).

order and orderby do not affect the database query. The tags are first retrieved from the database and then sorted. These parameters for retrieving from the database are: orderby=count and order=DESC and cannot be changed.
Default: "ASC"

Exclude (line) Exclude the specified labels. You need to specify the ID separated by commas.
Default: null include (line) Show only the specified tags. You need to specify the ID separated by commas.
Default: null topic_count_text_callback (string/array) A function that gets the number of entries and returns the text for the label. You can set your own function if you need to display some other text with the number of entries for each label.
Default: default_topic_count_text link (line)

  • view - clicking on a label will take you to the label’s page;
  • edit - clicking on a label will take you to the label editing page.
    Default: view
taxonomy (string/array)

The name of the taxonomy or an array of several names from which the cloud will be built. May be:

  • post_tag ;
  • category ;
  • link_category ;
  • Its own taxonomy;
  • Array of taxonomy names - this parameter was introduced in version 3.1.
    Default: post_tag
show_count (logical) Whether to show the number of records in the label. Default is 0. Can be: 0, 1 or true/false. With WP 4.8. echo (logical) 1 - Display, 0 - return the result for further processing.
Default: 1 (true)

Examples

#1 Basic use

Let's display a cloud of tags with the title "Popular tags":

Popular tags"; wp_tag_cloud("smallest=8&largest=22"); ) ?>

#1.2. Another example demonstrating the transfer of different parameters

Let's change the size of the labels (smallest=15&largest=40), limit the number of labels displayed (number=50) and sort them by the number of records, not by name (orderby=count):

#2 Let's get a list, we won't display it on the screen

Let's write the list in the $tag parameter so that we can later use it in PHP for our own purposes:

#3 Category Cloud

"category")); ?>

#3.1. Cloud of tags and categories at the same time

array("post_tag","category"),)); ?>

#4 Changing the text of the title attribute of a tag

"my_tag_text_callback")); function my_tag_text_callback($count) ( return sprintf(_n("%s picture", "%s pictures", $count), number_format_i18n($count)); ) ?>

#5 Archive of tags

As one of the options for using tags, I suggest creating archived tag pages. When we click on a specific tag, we are taken to a page with posts associated with that tag. What such a page looks like is determined by the template file tag.php , if there is no such file (usually its ent), then output generation is given to the archives.php file.

Let's make a tag page, which will show a cloud of tags at the very beginning, and after it the entries related to the selected tag. To do this, create (if not) or change (if exists) the tag.php file. You need to create the file in the theme directory.

Contents of the tags.php file:

Tag Archive

" rel="bookmark" title="Permanent Link to!}">

This example does not take into account CSS styles, so there may be incompatibility with the template.

#6 Changing default settings for the tag cloud widget through a filter

Let's say we need to reduce the maximum fonts for a widget with a cloud of labels. You need to set the value 16, not 22 for the "largest" parameter. To do this we use the widget_tag_cloud_args hook

Add_filter("widget_tag_cloud_args", function($args)( $args["largest"] = 16; return $args; ));

This comment prompted me to use this example.

Notes

  • In version 3.1, the ability to pass arrays to the taxonomy parameter was added;
  • In version 2.9 the separator parameter was added;
  • Version 2.8 added taxonomy and echo parameters;
  • In version 2.7 the link parameter was added;

Code wp tag cloud: wp-includes/category-template.php WP 5.2.2

8, "largest" => 22, "unit" => "pt", "number" => 45, "format" => "flat", "separator" => "\n", "orderby" => " name", "order" => "ASC", "exclude" => "", "include" => "", "link" => "view", "taxonomy" => "post_tag", "post_type" = > "", "echo" => true, "show_count" => 0,); $args = wp_parse_args($args, $defaults); $tags = get_terms($args["taxonomy"], array_merge($args, array("orderby" => "count", "order" => "DESC",))); // Always query top tags if (empty($tags) || is_wp_error($tags)) ( return; ) foreach ($tags as $key => $tag) ( if ("edit" == $args["link "]) ( $link = get_edit_term_link($tag->term_id, $tag->taxonomy, $args["post_type"]); ) else ( $link = get_term_link(intval($tag->term_id), $tag- >taxonomy); ) if (is_wp_error($link)) ( return; ) $tags[ $key ]->link = $link; $tags[ $key ]->id = $tag->term_id; ) $return = wp_generate_tag_cloud($tags, $args); // Here"s where those top tags get sorted according to $args /** * Filters the tag cloud output. * * @since 2.3.0 * * @param string $return HTML output of the tag cloud. * @param array $args An array of tag cloud arguments. */ $return = apply_filters("wp_tag_cloud", $return, $args); if ("array" == $args["format"] || empty($args["echo "])) ( return $return; ) echo $return; )

Quick navigation on this page:

Tags for a WordPress site not only help you design your site beautifully, but also improve navigation. Typically, a tag cloud can be used to group blog posts by topic, allowing users to find similar articles.

WordPress has a built-in tag cloud widget, so you don't have to reinvent the wheel to install standard tags. You just need to configure this widget by choosing the location of the cloud itself on the page - in the right (left) column or in the footer. It is usually better to place tags on the right side of the WordPress sidebar - the tags are more clickable and you will be able to increase the number of page views on your WordPress site.

However, sometimes the widget is not suitable. This can happen for two main reasons:

  • the standard cloud does not fit into the style (design) of the site;
  • you have too many tags for each post, but you want to display only a limited number.

WP-Cumulus Plugin - 3D Tag Cloud

The most commonly used plugin for creating a design cloud is called WP-Cumulus. It works using flash technology. It’s also easy to install—you just need to load it into your site’s plugins, and then check the boxes for the required settings. The widget works automatically and you should not implement a tag cloud script into the site code.

In order to insert a cloud from WP-Cumulus onto a site, you need to select a widget and drag it to the sidebar (such a tag cloud usually does not fit into the footer).

Want to add an interesting look to your cloud? Then open the settings and change them.

In settings you can:

  • set the required dimensions;
  • choose a color, gradient and other design parameters (all colors are indicated in the table);
  • 3D cloud rotation speed.

The latter is noted for the convenience of users. People must have time to click on the desired tag while the “globe” is spinning. It is also advisable to select the option of distributing tags evenly across the sphere, otherwise the tags may merge, colliding with each other.

Editing a Built-in Plugin in WordPress

Sometimes a webmaster doesn't need to reinvent the wheel; he wants to use a standard tag cloud. You just need to change a couple of parameters (for example, remove one frequently occurring tag that is an eyesore). The settings can be found in the wp-include/category-template.php file, in the wp_tag_cloud() function. Therefore, if you dream of changing tags for a website, you need to know html (at least the basics of this language).

The parameters that can be changed are:

  • smallest and largest - the smallest and largest font sizes;
  • unit — font size;
  • number - number of tags (if you want to display everything, use 0);
  • format — cloud format;
  • separator — type of separator between tags;
  • orderby — sorting the label cloud;
  • exclude - list of tags (via ID) required for exclusion;
  • include - the same thing, only these are the labels required for inclusion;
  • taxonomy - an array of names from which the label cloud will be built. Typically we need post tags: post_tag (post tags).

These are the two most common options for making a label cloud. Lately, many novice webmasters who like to do everything online are looking for how to create an online tag cloud.

Indeed, there are now a lot of services that generate tags online (TagCrowd, Word It Out, and so on). However, plugins or your own WordPress widget are much easier to use. After all, they are already tailored for this CMS, and work perfectly on it, which cannot be said about various external services.

On . Tags— these are the keywords that are assigned to your articles. These words are an additional connection between your articles, because with their help the articles are divided into separate topics. Articles are also distributed on individual topics using headings, but if one article is usually assigned one heading, then several tags are assigned.

Labels may be visible in the sidebar WordPress blog. tags in WordPress looks like a collection of individual words. Some words have a larger font, some smaller ones. If the font of a word is larger, this means that this tag has been assigned to more articles.

I recommend assigning the article three or four marks . In addition, the total number of tags on the entire blog should not be large. Quite enough 20−40 tags for the entire blog , no matter how extensive it may be.

If you click on any of the tags, you will see the articles to which that tag belongs. You can also bet on your WordPress blog Not static marks, and the cloud, consisting of labels.

WP-Cumulus or WP-Cirrus plugin

To put movable label cloud, you need to put the appropriate plugin. Install it in the same way as other plugins, namely: go to the administrative panel, in Plugins - Add new , write in the word search box Cumulus, and press the button Search for plugins .

A list of plugins appears, and in the first place you will see the following plugins:

  • WP-Cumulus
  • WP-Cirrus

Choose one of them. You can try both and see which one is better. If the plugin is not suitable for you, you can always remove it. Select the plugin, then click Install, then Activate .

Now we need to add the plugin to our sidebar. Come in Widgets. A widget will appear on the left WP-Cumulus, or WP-Cirrus, depending on what you chose. On the right, find the sidebar where you want to place this label cloud, and drag the widget to this sidebar. After dragging set it up : write a title, decide on the width and height, change the color of the words, make the background transparent.

Click Install, and look what you got.

Video on how to install a tag cloud plugin in WordPress

P.S.: Everything flows, everything changes... If earlier the cloud of tags did not particularly affect the results in search engines, now the presence of a cloud of tags is an additional disadvantage for your blog. So whether to put this widget on your blog or not is up to you. At least you now know how to do it.

You can get more detailed information in the “All courses” and “Utilities” sections, which can be accessed through the top menu of the site. In these sections, articles are grouped by topic into blocks containing the most detailed (as far as possible) information on various topics.

You can also subscribe to the blog and learn about all new articles.
It does not take a lot of time. Just click on the link below:

Tags are another functional element in the WordPress engine, which is used along with categories and the search bar. Thanks to them, you can improve behavioral factors on your web project, allowing the reader to search for similar publications using relevant words.

Often, the display of labels is already implemented in the design theme (at the end of each post), but in addition, you can use third-party plugins like “ ”, which create an original “label cloud” format. Or use the existing standard widget from the WordPress set, which will easily fit into any template design.

Label cloud

The standard “Tag Cloud” widget is located in the admin panel in the “Appearance” - “Widgets” section, and is installed like all other widgets (by dragging it into the active Sidebar or through the context menu).
Unlike third-party solutions, the “tag cloud” has minimal settings, prompting the webmaster to set a name for the title and mark the taxonomy output (in addition to tags, categories and custom data types will be shown).

The widget code itself, more precisely its “wp_tag_cloud” function, is located in the base WordPress directories (wp-includes), so editing the source is not recommended. But we can use another way to fine-tune the widget.

Tag Cloud settings

To make changes, you can create a separate function indicating the required parameters for a standard widget, or , and place a “label cloud” through a text widget.

I liked the method through the “Text” widget more, and my version took the following code:

Now in more detail about the function parameters that can be used to display labels:

  • smallest – minimum font size for less popular publications;
  • largest – maximum font size for the most popular publications;
  • unit – unit of measurement for font size, can take the following values: pt, px, %;
  • number – number of labels to display (default 45);
  • format – format for displaying links: flat (separated by a space – by default), list – UL list, array – like an array for PHP;
  • separator – value of the separator between labels (default – space);
  • orderby – sorting settings: name – alphabetically (default), count – by quantity;
  • order – sort order: ascending – ASC (default), descending – DESC, random – RAND;
  • exclude – tags that should be excluded from display;
  • include – labels that must be displayed.

Instead of an afterword

Thus, by editing the PHP code in the text widget, you can achieve the desired appearance for the “label cloud”. Now knowing the parameters, we see that the example I gave will display 30 labels with a font size of 9pt - 16pt, and sort them alphabetically (by name).

Do you want to place your tags on a cloud, or rather, on a dynamic cloud that is always in motion and attracts the attention of site visitors? I think so, because today I received several letters with a question: about the blog. And if there are those who still don’t know whether they need it or not, or don’t know what we’re talking about at all, then just look at the main page of my blog and rate how you like it WordPress tag cloud.

Let's get down to business: to install WordPress tag cloud needs to be installed and activated plugin W. P. Cumulus. Please note that you must download this plugin yourself from the Internet! Be sure to have the Russian version!! Otherwise, if you use the search on the Add plugin tab, the search will find an English version of this plugin, which will not be able to work correctly with your Russian tags.

  1. PUA - Plugin - Add plugin - Upload file.
  2. Activate.
  3. Configure the plugin.

What does it mean to configure a plugin? Let's not configure it and just see what our cloud looks like on the page!

To add a cloud to a page, select the Label Cloud Widget and drag it to the sidebar. Ready? Then proceed to view the main page of the site.

And How? All good?

  • Are you happy with the text color and background color?
  • Check how the tags work: click on any tag and see the result. By the way, did you manage to click on the tag? Are you satisfied with the rotation speed?
  • By the way, pay attention to whether your cloud fits into the size of the sidebar! During the initial installation, the cloud size did not match my sidebar.
  • How are your tags arranged? Don't you think they've huddled together? If yes, then you definitely need to check the box in the plugin settings to evenly distribute the tags on the cloud.

Therefore, after all, let's go back to the cloud settings page and correct everything that does not suit us.

To configure the plugin, feel free to click LMB on the name of the WP Cumulus plugin on the Settings tab. Make the changes you need, go to the site and admire the changes. Just ATTENTION, after making changes, be sure to check how it looks in reality, and if anything, return the parameters to their place.

By the way, these same plugin settings can be made if you click Placemark Cloud on the Widgets tab.

DO NOT FORGET! Please note that you must check the box

Places tags at equal distances from each other instead of random placement

otherwise your tags may get confused and you won’t get any pleasure or beauty from the cloud!

By the way, I almost forgot to warn you: plugin only need to be installed if there is at least one label!!! If there are no tags, be sure to open the articles and add tags!!!

Let's summarize:

  • found out why you need the WP Cumulus plugin
  • downloaded the WP Cumulus plugin
  • learned how to install, activate, configure plugin W.P. Cumulus
  • learned, how to install wordpress tag cloud to the blog

I tested the operation of this cloud for three months and decided that for now I would remove this cloud from my site. I'll test the blog without a tag cloud.







2024 gtavrl.ru.