Do you want to display the most popular tags used on your WordPress site? Tags and categories are the two default ways to sort your content in WordPress. Categories often get more exposure due to their broader scope, which gives tags a little less attention. In this article, we will show you how to easily display your most popular tags in WordPress.
您是否要显示WordPress网站上使用的最受欢迎标签? 标签和类别是在WordPress中对内容进行排序的两种默认方法。 由于类别的范围更广,因此类别通常会获得更多的展示机会,从而使标签的关注度降低。 在本文中,我们将向您展示如何轻松地在WordPress中显示最受欢迎的标签。
为什么以及何时应该在WordPress中显示最受欢迎的标签 (Why and When You Should Display Most Popular Tags in WordPress)
Categories and tags are the two default taxonomies 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 merge categories and tags 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 categories in navigation menus, 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 Appearance » Widgets page, and add Tag Cloud widget to a sidebar.
解决此问题的一种方法是,通过转到“ 外观»小部件”页面添加默认标签云小部件 ,并将标签云小部件添加到侧边栏。
However, you will notice that the default tags widget will show all your tags alphabetically. You cannot rearrange their order or limit the number of tags to be displayed.
但是,您会注意到默认标签小部件将按字母顺序显示所有标签。 您不能重新排列其顺序或限制要显示的标签数量。
You can solve this, by displaying the most popular or most often used tags on your WordPress site.
您可以通过在WordPress网站上显示最受欢迎或最常用的标签来解决此问题。
This will allow your users to quickly get an idea on what topics are more frequently discussed on your site. It will also help them discover more content, which means more page views and user engagement.
这将使您的用户快速了解您的站点上最经常讨论的主题。 它还将帮助他们发现更多内容,这意味着更多的页面浏览量和用户参与度。
Now let’s take a look at how to easily display your most popular tags in WordPress.
现在,让我们看一下如何轻松地在WordPress中显示最受欢迎的标签。
影片教学 (Video Tutorial)
If you don’t like the video or need more instructions, then continue reading.
如果您不喜欢该视频或需要更多说明,请继续阅读。
1.使用插件显示WordPress中最受欢迎的标签 (1. Display Most Popular Tags in WordPress Using Plugin)
This method is easier and recommended for most users.
此方法更简单,建议大多数用户使用。
First thing you need to do is install and activate the Simple Tags plugin. For more details, see our step by step guide on how to install a WordPress plugin.
您需要做的第一件事是安装并激活简单标签插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。
Upon activation, you need to visit Appearance » Widgets page and add ‘Tag Cloud (Simple Tags)’ widget to the sidebar.
激活后,您需要访问外观»小部件页面,并将“标签云(简单标签)”小部件添加到侧边栏中。
The widget will expand, and you will be able to see its settings.
小部件将展开,您将能够看到其设置。
Here you can select the number of tags you want to display, font sizes, colors, etc.
在这里,您可以选择要显示的标签数量,字体大小,颜色等。
To display your tags by popularity, make sure you select count for ‘Order by for display tags’ and descending for ‘Order for display tags’ options.
要按受欢迎程度显示标签,请确保为“显示标签订购依据”选择计数,并为“显示标签订购依序”选项递减。
Don’t forget to click on the save button to store your widget settings.
不要忘记单击“保存”按钮来存储您的小部件设置。
You can now visit your website to see your popular tags in action.
现在,您可以访问您的网站以查看流行的标签。
手动显示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 how to copy and paste code in WordPress.
此方法要求您在WordPress主题文件中添加代码。 如果您之前没有做过,请参阅我们的指南, 了解如何在WordPress中复制和粘贴代码 。
First, you need to add this code to your theme’s functions.php file or a site-specific plugin.
首先,您需要将此代码添加到主题的functions.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 shortcode wpb_popular_tags
and enables shortcode in text widget.
此代码仅会在云中从您的网站生成前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 how to style tags in 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 most wanted WordPress tips, tricks, and hacks for beginners.
我们希望本文能帮助您学习如何在WordPress中显示最受欢迎的标签。 您可能还希望查看初学者最想要的WordPress技巧,窍门和黑客列表。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/plugins/how-to-display-most-popular-tags-in-wordpress/