Browsing Categories and Tags Using a Web Address

Earlier, you saw how the Categories widget lets you retrieve a list of posts for any
category. For example, click the Herbal Tea link and—presto!—you see the posts
about brewing your favorite dried leaves.
WordPress works this category-browsing magic using a specific form of web address.
If you understand it, then you can use category web addresses yourself, wherever
you need them. First, you start with the site address:
http://magicteahouse.net
Then, you add /category/ to the end of the address, like this:
http://magicteahouse.net/category/
Finally, you add the bit that identifies the category you want to use. If you use the
default permalink style on a self-hosted site, you get awkward category web addresses
that incorporate the category ID:
http://magicteahouse.net/category/?cat=6
But if you use pretty permalinks, life is much better. Then, instead of embedding
the category ID, category web addresses use the much more readable category
slug, like this:
http://magicteahouse.net/category/herbal-tea
WordPress cooks up the slug based on your category name, using the same process
it follows to pick the slug for a new post. First, WordPress replaces every uppercase
letter with a lowercase one. Next, it replaces spaces with hyphens (-). Lastly, it strips
out forbidden special characters, if you used them. As a result, the category Herbal
Tea gets the slug herbal-tea.
Remember, you can modify the slug for every category using the Categories page
(page 113). For example, you can shorten the address shown above by replacing
herbal-tea with the simpler slug herbal.
Tags work the same way as categories, except the /category/ portion of the web
address becomes /tag/. So, to browse the posts that use a specific tag, you need
an address like this:
http://magicteahouse.net/tags/kuala-lumpur
You can tweak tag slugs in the Tags page. However, it’s far less common to tailor
tag slugs than it is to edit post and category slugs.

Browsing Categories and Tags Using a Web Address

Making Your Shortlinks Even Smaller

If you have a self-hosted WordPress site, the shortlink
might not be as short as you want. It works great if you use
WordPress to run your entire site and you have a nice, short
domain name. But if you have a long domain name with your
WordPress content in a subfolder, you end up with a not-soshort
shortlink, like this:
http://prosetech.com/wordpress/magicteahouse/?p=4
It might occur to you to use the WP.me service to get an
even shorter web address, but unfortunately it’s limited to
WordPress.com sites. However, there are other URL-shortening
services that will take your address and spit out a tinier
version. Popular shortener sites include http://bit.ly (which
Twitter uses for automatic URL-shrinking), http://tinyurl.com,
and http://tiny.cc.
For example, if you plug your web address into bit.ly, you get
a new one, like this:
http://bit.ly/LejGs9
Weighing in at a mere 20 characters, this address is even
shorter than the ones WP.me creates. If someone types that URL
into a browser, they’ll go first to the bit.ly web server, which
will quickly redirect the browser to the original web address.
The end result is that your post appears almost immediately.
Using any of these URL-shortening services is easy. Just go to
the website, paste in your web address—either the permalink
or shortlink, it doesn’t matter—and then copy the new condensed
address.

:现在许多新的短地址服务淘汰旧服务,可以关键词搜索‘短地址服务’。

Making Your Shortlinks Even Smaller

Tags guidelines

Tags are often more specific than categories. For example, if you write a review of
a movie, you might use Movie Reviews as your category and the movie and director’s
name as tags.
Follow these guidelines when you use tags:
Don’t over-tag. Instead, choose the best five to 10 tags for your content. If you
use WordPress.com and you create a post with 15 tags or more, it’s much less
likely to appear in the WordPress.com tag cloud (page 41), which means new
visitors are less likely to stumble across your blog.
Keep your tags short and precise. Pick “Grateful Dead” over “Grateful Dead
Concerts.”
Reuse your tags on different posts. Once you pick a good tag, put it to work
wherever it applies. After all, tags are designed to help people find related
posts. And never create a similarly named tag for the same topic. For example,
if you decide to add the tag “New York Condos,” and then you use the tags “NY
Condos” and “Condo Market,” you’ve created three completely separate tags
that won’t share the same posts.
Consider using popular tags. If you’re on WordPress.com, check out popularly
used tags (page 39) and consider using them in your posts, when they apply.
If you’re trying to attract search engine traffic, you might consider using hot
search keywords for your tags (page 448).
Don’t duplicate your category with a tag of the same name. That’s because
WordPress treats categories and tags in a similar way, as bits of information
that describe a post. Duplicating a category with a tag is just a waste of a tag.

Tags guidelines

A tree of categories lists

When you start adding subcategories to your site, you’ll probably be disappointed
by how they appear in the Categories list, the category-browsing links that appear
in the sidebar alongside your posts. The standard list of categories is a flat, onedimensional
list in alphabetical order. You can’t see the relationships between parent
categories and subcategories

NOTE The Categories list shows only the categories you currently use. So if you create a new category but
don’t assign it to a post, you won’t see it in the Categories list.

Fortunately, it’s easy to change the standard list of categories into a tree of categories,
by borrowing a theme-altering trick you’ll explore in more detail in the next
chapter. Technically, the Categories list is known as a widget. Like all widgets, it can
be moved, removed, and reconfigured. Here’s how:
1. On the dashboard, choose AppearanceÆWidgets.
The Widgets page shows you all the individual ingredients that WordPress puts
into the sidebar on your site.
2. In the Main Sidebar box, find the Categories widget.
This is the widget that creates the list of categories that appears next to your
posts.
3. Click the down-pointing arrow on the right side of the widget.
This expands the Categories widget, so you can see its settings.
4. Turn on the checkbox in the “Show hierarchy” settings and then click Save.
Now return to your site and admire the result (Figure 4-20, right).

NOTE No matter what setting you tweak, WordPress always orders categories alphabetically. If you want
to put a specific category on top, you need to put in some extra work and create a menu (page 218).

A tree of categories lists

Pick the subcategory only

NOTE When you assign post to a subcategory, make sure you pick the subcategory only, not the parent
category. That means that if you want to add a post about green tea, you should turn on the checkbox next to
the Green Tea box, but not the Tea box. Because Tea is the parent category, people who browse the Tea category
will automatically see your Green Tea posts.

NOTE Yes, you can create subcategories inside of subcategories. But doing so can complicate life and make
it more difficult to fit a proper category tree in your sidebar. If possible, stick with one level of subcategories

Pick the subcategory only

How to Choose Good Categories

To choose the right categories, you need to imagine your site,
up and running, several months down the road. What posts
does it have? How do people find the content they want? If
you can answer these questions, you’re well on the way to
choosing the best categories.
First, you need to choose categories that distribute your posts
well. If a single category has 90 percent of your posts, you
probably need new—or different—categories. Similarly, if a
category accounts for less than 2 percent of your posts, you
may have too many categories. (Although there are exceptions—
perhaps you plan to write more on that topic later, or
you want to separate a very small section of special-interest
posts from the rest of your content.)
You may also want to factor in the sheer number of posts you
plan to write. If your site is big and you post often, you may
want to consider more categories. For example, assuming the
Magic Tea House has a couple of dozen posts, a category split
like this works fine: Tea (70 percent), Concerts (20 percent),
News (10 percent). But if you have hundreds of posts, you’ll
probably want to subdivide the big Tea group into smaller
groups.
It also makes sense to create categories that highlight the
content you want to promote. For example, if you’re creating
a site for a furniture store, you’ll probably create categories
based on your products (Couches, Sofas, Dining Room Tables,
and so on). Similarly, the Magic Tea House can split its Tea
category into Our Teas and Tea Facts to better highlight the
teas it sells (Figure 4-16).
Finally, it’s important to consider how your readers will want
to browse your information. If you’re a lifestyle coach writing
articles about personal health, you might decide to add
categories like Good Diet, Strength Training, and Weight Loss,
because you assume that your readers will zero in on one of
these subjects and eagerly devour all the content there. Be
careful that you don’t split post categories too small, however,
because readers could miss content they might otherwise
enjoy. For example, if you have both a Good Diet Tips and
Superfoods category, a reader might explore one category
without noticing the similar content in the other. This is a
good place to apply the size rule again—if you can’t stuff both
categories full of good content, consider collapsing them into
one group or using subcategories

How to Choose Good Categories

change the slug

However, pretty permalinks aren’t always as pretty as they should be. The problem
is that a post title doesn’t necessarily fit well into a web address. Often, it’s overly
long or includes special characters. In this situation, you can help WordPress out
by explicitly editing the slug—the version of the post name that WordPress uses in
your permalinks.

You can change the slug when you add or edit a post. Here’s how:

1. Find the permalink line, which appears just under the post title text box.
WordPress creates the slug automatically, once you type in the post title and
start entering the post content. After that point, the slug doesn’t change, even
if you edit the title, unless you edit it explicitly.

2. Click the Edit button next to the permalink line .
WordPress converts the portion of the permalink that holds the slug into a text
box. You can then edit to your heart’s content, so long as you stay away from
spaces and special characters, which aren’t allowed in URLs. The best permalinks
are short, specific, and unlikely to be duplicated by other posts. (Although
WordPress is smart enough to refuse to use a slug you assigned to another post.)
NOTE If you see a Change Permalinks button next to the permalink where the Edit button should be, you
don’t have pretty permalinks turned on. To fix the problem, follow the steps on page 117.

3. Click OK to make your change official.

change the slug