您想显示 WordPress 网站上最常用的标签吗?标签和类别是 WordPress 中对内容进行排序的两种默认方式。由于类别范围更广,类别通常会获得更多曝光,这使得标签受到的关注较少。在本文中,我们将向您展示如何轻松地在 WordPress 中显示最流行的标签。
您想显示 WordPress 网站上最常用的标签吗?标签和类别是 WordPress 中对内容进行排序的两种默认方式。由于类别范围更广,通常会获得更多展示次数,而标签的关注度却较低。在本文中,我们将向您展示如何轻松地在 WordPress 中显示最流行的标签。

为什么以及何时应该在WordPress中显示最受欢迎的标签 (Why and When You Should Display Most Popular Tags in WordPress)
类别和标签 are the two default 分类法 to sort your articles in WordPress. Categories are used for broader topics or sections on your website while tags are well-suited to specific ideas within the context of your articles.
类别和标签是在WordPress中对您的文章进行排序的两个默认分类 。 类别用于网站上更广泛的主题或部分,而标签则非常适合您文章上下文中的特定思想。
Often beginners end up using them incorrectly, but there are easy tools which allow you to 合并类别和标签 and even convert them.
通常,初学者最终会错误地使用它们,但是有一些简单的工具可让您合并类别和标签 ,甚至进行转换。
Once you start using categories and tags correctly, you’ll likely have more tags on your website than categories. Due to their broader scope, you can put 导航菜单中的类别, but your tags may often remain less explored.
一旦开始正确使用类别和标签,您的网站上的标签可能会比类别更多。 由于它们的范围更广,因此您可以在导航菜单中放置类别 ,但是您的标签可能经常没有被浏览。
One way to deal with this is by adding the default tag cloud widget by going to the 外观 » 小部件 page, and add Tag Cloud widget to a sidebar.
解决此问题的一种方法是,通过转到“ 外观 » 小部件”页面添加默认标签云小部分 ,并将标签云小部件添加到侧边栏。

但是,您会注意到默认标签小部件将按字母顺序显示所有标签。您无法重新排列它们的顺序或限制要显示的标签数量。
但是,您会注意到默认标签小部件将按字母顺序显示所有标签。您无法重新排列其顺序或限制要显示的标签数量。
您可以通过在 WordPress 网站上显示最流行或最常用的标签来解决此问题。
您可以通过在 WordPress 网站上显示最流行或最常用的标签来解决此问题。
这将使您的用户能够快速了解您的网站上更常讨论哪些主题。它还将帮助他们发现更多内容,这意味着更多的页面浏览量和用户参与度。
这将使您的用户快速了解您网站上最常讨论的主题。它还将帮助他们发现更多内容,这意味着更多的页面浏览量和用户参与度。
现在让我们看看如何在 WordPress 中轻松显示最流行的标签。
现在,我们来看看如何轻松地显示WordPress中最流行的标签。
影片教学 (Video Tutorial)
如果您不喜欢该视频或需要更多说明,请继续阅读。
如果您不喜欢该视频或需要更多说明,请继续阅读。
1.使用插件显示WordPress中最受欢迎的标签 (1. Display Most Popular Tags in WordPress Using Plugin)
此方法更简单,推荐大多数用户使用。
此方法比较简单,推荐大多数用户使用。
First thing you need to do is install and activate the 简单标签 plugin. For more details, see our step by step guide on 如何安装 WordPress 插件.
您需要做的第一件事是安装并激活简单标签插件。 有关更多详细信息,请参阅有关如何安装 WordPress 插件步指南。
Upon activation, you need to visit 外观 » 小部件 page and add ‘Tag Cloud (Simple Tags)’ widget to the sidebar.
激活后,您需要访问外观 » 小部件页面,并将“标签云(简单标签)”小部件添加到侧边栏中。

该小部件将展开,您将能够看到其设置。
该小部件将展开,您将能够看到其设置。
在这里您可以选择要显示的标签数量、字体大小、颜色等。
在这里您可以选择要显示的标签数量、字体大小、颜色等。
要按受欢迎程度显示标签,请确保为“显示标签排序依据”选择计数,并为“显示标签排序”选项选择降序。
要按受欢迎程度显示标签,请确保为“显示标签排序依据”选项选择“计数”,并为“显示排序依据”选项选择“递减”。
不要忘记单击“保存”按钮来存储您的小部件设置。
不要忘记单击“保存”按钮来存储您的小部件设置。
您现在可以访问您的网站以查看正在运行的热门标签。
现在您可以访问您的网站以查看热门标签。

手动显示WordPress中的热门标签 (Display Popular Tags in WordPress Manually)
This method requires you to add code in your WordPress theme files. If you haven’t done this before, then please see our guide on 如何在 WordPress 中复制和粘贴代码.
此方法要求您在WordPress主题文件中添加代码。 如果您之前没有做过,请参阅我们的指南, 了解如何在 WordPress 中复制和粘贴代码 。
First, you need to add this code to your theme’s 函数.php file or a 特定于站点的插件.
首先,您需要将此代码添加到主题的函数.php文件或具体的于在网站的插件中 。
function wpb_tag_cloud() {
$tags = get_tags();
$args = array(
'smallest' => 10,
'largest' => 22,
'unit' => 'px',
'number' => 10,
'format' => 'flat',
'separator' => " ",
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'echo' => false
);
$tag_string = wp_generate_tag_cloud( $tags, $args );
return $tag_string;
}
// Add a shortcode so that we can use it in widgets, posts, and pages
add_shortcode('wpb_popular_tags', 'wpb_tag_cloud');
// Enable shortcode execution in text widget
add_filter ('widget_text', 'do_shortcode');
This code simply generates the top 10 tags from your website in a cloud with number of posts in each tag. After that it creates a 短代码 wpb_popular_tags
and 在文本小部件中启用短代码.
此代码仅会在云中从您的网站生成前10个标签,每个标签中的帖子数。 之后,它将创建一个短代码 wpb_popular_tags
并在文本小部件中启用简码 。
You can now add shortcode [wpb_popular_tags]
in any post, page, or widget to display your most popular tags.
现在,您可以在任何帖子,页面或小部件中添加简码[wpb_popular_tags]
,以显示最受欢迎的标签。

Want to style your tags differently? Check out our guide on 如何在 WordPress 中设置标签样式 for detailed instructions and example.
想要以不同的方式设置标签样式吗? 查看有关如何在 WordPress 中设置标签样式指南, 经过获取详细说明和示例。
We hope this article helped you learn how to display most popular tags in WordPress. You may also want to see our list of 最想要的 WordPress 提示、技巧和技巧 for beginners.
我们希望本文能帮助您学习如何在WordPress中显示最受欢迎的标签。 您可能还希望查看初学者最受欢迎的 WordPress 提示、技巧和技巧列表。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/plugins/how-to-display-most-popular-tags-in-wordpress/