Creating Custom Category Pages

Now that you’ve picked a theme, created a custom post type, and added a bit of
sample content, you’re ready to start reengineering your site. Your goal is to remove
the “bloggish” details that don’t really fit, and make your site feel like a fine-tuned
custom creation.
The first challenge is to give your visitors a decent way to browse Distinct Furnishing’s
products. Right now, WordPress sorts the products the same way that it sorts
posts—in reverse-chronological order, based on the date you published the post.
While that makes sense for a blog, a news website, and many other types of sites, it
isn’t terribly useful in a product catalog. Visitors who arrive at Distinct Furnishings
probably won’t want to see every item crowded into a somewhat disordered single
page of tiles . Instead, they’ll want to focus on the type of furniture they
need—like a sofa, chair, or table.

This is clearly a job for the WordPress category system. As you already know, you can
browse posts by category by putting the category name in the web address, like this:
http://distinctfurnishings.net/sofas
Of course, you won’t expect your visitors to type this address on their own. Instead,
you’ll supply the links in a post or page, in the Categories widget, or in a menu. Menus
are the most common way that visitors navigate sites.

The menu approach is probably the best browsing experience you can create without
editing your theme. However, it’s not perfect. It has several shortcomings:

• You can’t display different categories of products in different ways. For example,
you might want the sofa-browsing page to look different from the
tables-browsing page.

• You can’t display additional information about a category.

• You can’t control the order of products within a category—WordPress still puts
them in reverse-chronological order by publication date.

However, you can control all these options by customizing the category page template
(also known as a category archive page), which creates the page . For example, when you visit a web address like http://distinctfurnishings.net/
sofas, the category page grabs the products in the Sofas category and displays them.
The stock category page does a decent enough job, but you can do better by editing
your theme.

Creating Custom Category Pages

Adding a Category Description

The first and easiest change you can make to the category page template is adding
a category description. Many themes, including PinBlack, automatically display the
category description on the category page. You don’t even need to edit your theme.
When you first create a category, it doesn’t have a description, but you can easily
add one to the category record. Start by choosing Posts→Categories to see a list
of all your categories, and then click the Edit link under the category you want to
edit. Then type the category description in the Description box.
TIP Although the Description box doesn’t give you the editing conveniences you get when editing a post or
a page, you can still type in any HTML you want. For example you can insert <img> elements that show pictures,
<a> elements that create links, and formatted <div> elements that use classes from the style.css file.

Adding a Category Description

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

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