Friends who use WordPress to build websites are very familiar with tags. Everyone has their own opinions on the use of tags, mainly focusing on two points: one is to block, and the other is not to block. The reason for blocking is that as the number of articles increases, there will be more and more tags, resulting in a bloated website; the reason for not blocking is that tags are beneficial to search engine inclusion. The author believes that this tag should not be blocked. As one of the blogging programs with the most users, wordpress naturally has its advantages. Below, the author will list and comment on the current popular usage, and provide an advanced usage to share with netizens.
1. Flashy tag cloud
I remember many years ago, when I didn’t use WordPress, I saw many netizens’ blogs with tag clouds on the sidebar, and some were like dynamic floating clouds. But I was using a domestic CMS system, so I tried hard to achieve the same function but couldn't find it. Later I found out that I was using wordpress and there was a tag cloud plug-in. Now it seems that this is nothing. For this kind of floating function, it is actually a flashy function. For users, the more important thing is the access speed. When the general network speed is not fast, the user's tolerance to load that thing is limited.
2. Practical popular tags
Under the navigation bar of the website, if there is a popular tag, it will undoubtedly make users feel that the website is professional. When using the CMS system in the past, the website background provided the input of popular tags. Obviously this kind of label is fake and not necessarily really popular. And using wordpress tags, you can truly achieve popular tags. As you add more articles, the tags will change. Especially when some use wordpress to build CMS websites, it seems to have become a standard configuration.
3. The outdated function of using tags as keywords
There was a time when meta tags (only considering keywords and descriptions) in websites were a must-have for SEO. However, after Baidu’s major update, the role of keywords has become increasingly weakened. You can look at Baidu's products such as Baidu Zhizhi, Baidu Encyclopedia, etc., and you can hardly see the setting of keywords. This shows that keywords are a dispensable identifier for search engines. Search engines can already analyze the content of the web page itself when judging the key points of a web page. In fact, wordpress itself has no place to set keywords. It can be seen that it is not necessary to use tags as keywords.
4. Use tags to enhance user experience
Obviously, WordPress users will be wondering, so how do I use tags? What I am saying is using tags to enhance the user experience of the website. We all know that a website has its main keywords. Assuming that our website has three main keywords, there may be hundreds of long-tail keywords derived from these three keywords. We should use these long-tail keywords when publishing articles or products, and then use tags to organize these keywords and place them in appropriate locations on the website to guide users to access, so that users can quickly find the information they need. I guess that's what labels are for. At least this way, your users won't get lost on your site.
5. Advanced usage of labels
In fact, tags are used to organize the content of the website, so how to organize the content? This requires certain skills. Let me illustrate this through a few examples.
Example 1: Use tags to create navigation.
Background assumption: There is a website that deals with Chinese poetry. This will involve dynasties and authors, and some will also require alphabetical classification. Although we can classify dynasties, the author cannot use classification because there are too many. There are only 26 letters that can be divided into categories, which also feels like the categories are too huge. So doing this by classification is not a good solution, so how to do it?
The solution is as follows:
Now we enter a poem "Looking at Lushan Waterfall" by Li Bai. We can enter this tag: W, Tang Dynasty, Li Bai, Qiyan. Then add the following code to the function.php file:
add_action('admin_menu', array('DJpluginsOptions', 'add'));
function get_tag_link_by_slug($tag_slug) {
$tag=get_term_by( 'slug', $tag_slug, 'post_tag' );
if ($tag) return get_tag_link($tag->term_id);
return 0;
}
The function of this function is to get the link of the tag, and then you can make the following reference in the template:
<a href="[?php echo get_tag_link_by_slug('tag name'); ?>">Tag name</a>
At this point, we can make the navigation we need.
Example 2: Use tags to identify projects.
Background assumption: We are now going to make a product-type corporate website. For a product, it involves price, specifications, color, material, details and other information. Although these can all be added in the editor, the problem is that this information cannot be presented separately. So we can only need other methods, such as putting details in the editor and putting others in labels. These labels require multiple input boxes to be easily called.
The solution is as follows:
Add some code to the function.php file:
function create_my_taxonomies() {
register_taxonomy('price', 'post', array(
'hierarchical' => false, 'label' => 'price',
'query_var' => true, 'rewrite' => true));
}
add_action('init', 'create_my_taxonomies', 0);
Here we only take "price" as an example, and the rest are analogous. After adding the above code, the "Price" input box will appear in the WordPress backend. When publishing a product, you only need to enter the price in the "Price" input box. Then enter the calling code in the appropriate position of the template to achieve the functions we need:
<?php echo get_the_term_list($post->ID, 'Price', 'Price: ', ', ', ''); ?>
Of course, the use of labels is much more than these, I just played a role here to inspire others. More advanced usages await further discovery. And I hope netizens will share it in the spirit of sharing.
This article is an original article from the author's blog Dianjin Theme Network www.dianjin123.com . Reprinting is welcome, but please keep the link, thank you!
(Editor: Yang Yang) Author echo's personal space