WordPress Label Advanced usage have you used it right?

Source: Internet
Author: User
Tags php file tag name

Use the WordPress build station friend, to label is again familiar. The use of the label is also different views, mainly concentrated in two points: one is inclined to shield, the other is not shielded. tend to block the reason is that with the increase in the number of labels will be more and more, resulting in a bloated web site; The reason for not shielding is that the label is conducive to the search engine included. I think this label should not be shielded, WordPress as the most users of the blog program, Nature has its beauty. The following author on the current popular usage do a list and comment, and provide a high-level use, and share with users.

One, the gaudy label cloud

Remember many years ago, no use of WordPress, see a lot of netizens blog, the sidebar has a label cloud, there are some of that dynamic cloud. But I use the domestic CMS system, so painstakingly seek to achieve the same function and not the end, then know is using WordPress, and there is a tag cloud plug-ins. Now it seems that this is nothing. For this floating function, in fact, is a flashy function, for users, more important is the speed of access, for the general speed of the situation, to load that thing, the user's endurance is limited.

Second, the practical hot tag

Under the navigation bar of the website, if there is a popular tag, it will no doubt make users feel that the site's professional. Before using the CMS system, the website backstage provided the popular label input. Obviously this label is fake and is not necessarily really hot. and using WordPress tags, you can really achieve popular tags. As you increase the number of articles, the labels will change. In particular, some use WordPress as a CMS site, it seems to be a standard.

Third, the outdated use of tags to do keyword function

Once, the website of the META tags (only consider keywords and description) is SEO necessary. But after Baidu's big update, the role of the key words increasingly weakened. We can see Baidu's products such as Baidu know, Baidu Encyclopedia, and so on, almost do not see the setting of the keyword, which means that the keyword for the search engine is an optional logo. But the search engine Judgment webpage key already can do from the webpage itself content analysis comes out. In fact, WordPress itself does not set the keyword place. It is not necessary to use tags to make keywords.

Iv. using tags to enhance the user experience

Obviously, WordPress users will be puzzled, then how do I use the label? What I want to say is to use tags to enhance the user experience of the site. We all guide, a site has its main keyword, assuming that our site's main keyword has three, then from these three keywords derived from the long tail keyword may have hundreds of. When we publish articles or products, we should use these long tail keywords, and then use the tags to organize these keywords, put them in the appropriate location of the site, guide users to visit, but users quickly find the information they need. I think that's how the label works. At the very least, your users will not lose their way in your site.

V. Advanced usage of labels

In fact, the label is used to organize the content of the site, then how to organize content? This requires some skill. Let me give a few examples to illustrate.

Example 1: Use tags to establish navigation.

Background hypothesis: There is a website, do Chinese poetry, this will involve dynasties, authors, and some will also ask to do alphabetically classification. Although dynasties we can use the classification to do, but the author cannot use the classification to do, because too many. There are only 26 letters that can be categorized, and the same sense of classification is too large. So it's not a good solution to classify, so how do you do that?

The solution is as follows:

Now we enter a piece of Li Bai's "Wang Lushan Waterfall" This poem, we can enter this tag: W, Tang, Li Bai, seven words. Then add the following code to the funtion.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 a link to 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 the label to do the project identification.

Background hypothesis: We now want to do a product class enterprise Web site, for a product, involving prices, specifications, colors, materials, details and other information. Although all of these can be added to the editor, the problem is that you cannot put this information alone. So we can only demand other options, such as putting the details in the editor and putting the rest in the tag. These tags need to design multiple input boxes for easy invocation.

The solution is as follows:

Add some code to the funtion.php file:

function create_my_taxonomies() {

register_taxonomy('price', 'post', array(

'hierarchical' => false, 'label' => '价格',

'query_var' => true, 'rewrite' => true));

}

add_action('init', 'create_my_taxonomies', 0);

Here we only take "price" as an example, the other analogy. Add the above code, WordPress backstage will appear "price" input box, release the product only in the "price" input box input price can be. Then enter the calling code at the appropriate location in the template to achieve our desired function:

<?php Echo get_the_term_list ($post->id, ' price ', ' Price: ', ', ', ');?>

Of course the use of the label is much more than that, I just played a role in the play. More advanced usage remains to be found. And hope that users in the spirit of sharing to share it out.

This article for the original article, the author blog Point Gold Theme network www.dianjin123.com, welcome reprint, but please keep the link, thank you!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.