{"id":205046,"date":"2015-07-21T04:00:09","date_gmt":"2015-07-21T11:00:09","guid":{"rendered":"http:\/\/css-tricks.com\/?p=205046"},"modified":"2019-12-06T08:11:00","modified_gmt":"2019-12-06T15:11:00","slug":"how-and-why-to-convert-wordpress-tags-from-flat-to-hierarchical","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/how-and-why-to-convert-wordpress-tags-from-flat-to-hierarchical\/","title":{"rendered":"How (and Why) to Convert WordPress Tags from \u2018Flat\u2019 to \u2018Hierarchical\u2019"},"content":{"rendered":"
The following is a guest post by Thomas McGee (@ThomasEMcGee<\/a>) from Writely Designed<\/a>. Thomas has found that having the ability to do parent\/child tags in WordPress can be useful. But, you’ll have to do some work if you want to do it, since WordPress doesn’t offer this by default.<\/em><\/p>\n <\/p>\n WordPress tags are pivotal to the organization methodology of the platform. Some sites get by with using categories only, but for most, categories and tags are like bread and butter—an inseparable team<\/em> that helps make content manageable, tidy, and easy to find for readers.<\/p>\n Whether you’re a WordPress newbie or experienced professional, it’s likely that you’ve experienced the difference between the two WordPress organizational tools. Categories are “hierarchical”, meaning they are able to hold parent items and sub-items. Also, categories maintain a running checkbox “list” of all the categories you’ve previously created and used.<\/p>\n Tags, on the other hand, are “flat” and do not contain any parent or child items—everything is on the same “level” so to speak. Rather than the “checklist” format afforded to the category, tags display a simple text box where you’re able to enter comma-separated items. In a fashion similar to categories, you’re able to view “most used tags” in a “tag cloud” format. The trouble with this, if you’re interested in having fine-tuned control over the organization of your tags, is that this can become messy in the blink of an eye.<\/p>\n Categories are typically used for broad or generic topics, whereas tags get a little more specific. If we were to use the example of a news website, it might use a category for “Technology” and a tag for something like “Apple.”<\/p>\n Explanations aside, in this article I’ll explore how (and why) to convert standard “flat” WordPress tags into a hierarchical, category-like format.<\/p>\n “I already have categories which operate like categories, why would I want my tags to operate like categories as well?”<\/i><\/p>\n I would’ve asked the same question had I not tried it out for myself in one of the WordPress themes I was building. However, in the time I’ve experimented with the concept, I’ve found only advantages. Advantages, that is, if organization and maintainability are important to your (or your user’s) WordPress structure.<\/p>\n One of the useful traits of tags is that they are a means separate from categories for organizing content. As I touched on above, categories work great for the most generalized content and tags, the specific.<\/p>\n While tags are excellent for quickly rattling off topics relevant to the article, it’s easy for tags to become cluttered, messy, and inconsistent. Multiply this by ten or a hundred if you have a wide variety of contributors with the ability to add tags themselves.<\/p>\n An aid to the problem is to convert tags over to a hierarchical format. The methodology remains the same; that is, categories stick to general topics and tags specific, but with the added benefit of more structure for the upkeep of tags.<\/p>\n “But I like being able to just type out tags in succession.”<\/i><\/p>\n While a hierarchical tag meta box will not allow you to do the normal comma-separated entry method, you’re still able to type out titles in rapid succession. This is possible because WordPress is smart enough to know when a category (or tag, in our case) already exists, and will check that item rather than creating a duplicate. The result is the ability for you or your user to type out tags in succession or click the checkboxes to assign the relevant tags to the post.<\/p>\nWhy Would You Want ‘Hierarchical’ Tags?<\/h3>\n