O'Reilly logo

Head First WordPress by Jeff Siarto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4 users, categories, and tags

Keeping things organized

Image

It’s time to invite some friends to the party.

Blogging (or managing a WordPress site) doesn’t have to be a solitary venture. Loads of well-know blogs out there feature multiple user roles, from writers to editors and administrators. In this chapter, you’ll learn how to get multiple people posting on the same blog, manage the workflow across all those people, and put categories and tags to work in organizing your site’s content.

You’re the new editor of Thanks for Mutton

Thanks for Mutton is an online magazine—OK, a blog—that publishes about food and cooking from a uniquely geeky point of view. You’ve been brought in to bring some organization not only to the site (which runs on WordPress) but also to your group of staff writers and contributors. Let’s take a look and see what you’ve got to work with.

Image
Image
Image
Image

WordPress user roles

A “user” in WordPress is any person that has access to your site with a username and password. WordPress allows you to add multiple users and give each of those users a role within the system. For example, we could have a main administrator that controls all aspects of the site and an editor that can only review and publish content but has no access to core WordPress settings. In general, user roles adhere to a heirarchical structure:

Image

The anatomy of a WordPress user

You are in control of adding users to your system, but WordPress is also set up to support visitors creating their own accounts too (so they can leave comments, for example). In this chapter, we focus on user accounts that you set up for people to write for your blog. Let’s take a look at the options you have for users in your WordPress dashboard.

Image
Image

Let’s see how the dashboard profile looks from a user’s perspective...

A sample user profile

Image
Image

Match users to their appropriate roles

If you set up your blog to have 5 administrators and 20 people that all have access to publish content to the live site whenever they want, you’re going to have problems. It may seem a bit foreign at first, but for each user, spend a bit of time thinking about what they are doing on the site, and how much responsibility they should be given. Beyond that, here’s a good rule of thumb based on the user hierarchy pyramid: The higher the role in the system, the fewer users should be assigned to that role.

Image

Who gets the nice wine glass at your party, and who gets the plastic cup?

Avoid chaos with an editorial workflow

Image

Now that we have a group of users with specific roles for Thanks for Mutton, we can take a quick look at what the editorial workflow might look like. The term “workflow” simply refers to how pages and posts move betwen content producers and editors when some form of review and approval is required— potentially multiple times—before somthing is published. The site has two main content producers: authors, who are staff writers with publishing rights, and contributors, who are contract or seasonal writers that submit stories for publication.

Image

Review pending posts from the admin dashboard

Once a post is submitted for review, the editors and administrators need to be able to read it, make changes, and then post it to the site.

Image Submit for Review.

Contributors submit articles for review by editors. These posts will show “pending” until they’ve been approved.

Image

Image As an editor (or and administrator) you can publish pending posts.

When an editor sees pending posts, they have the options to read and edit the content before it goes live on the site.

Image

Things are starting to look more organized...

Image

Categories are big buckets for your content

Image

Categories aren’t always required for blogs, but most of the time it helps to have some organizational structure to your posts. Think of categories as broad “buckets” that describe or hold your content in WordPress. Once a post is assigned to a category, it can be displayed in WordPress alongside other posts within the same category. They also give visitors a snapshot of what type of content they can expect on your site and help them find other posts they might be interested in.

Image

Categories help organize your content

When creating categories, think about the big concepts behind particular posts—and even behind the site as a whole. Categories should be very well thought out—almost sacred—so don’t just add them on a whim. If you find yourself adding lots of different categories, you’re probably not being broad enough. Categories represent the main areas of content of your site, so treat them accordingly.

Image

Content is key when creating category structures

As the editor of Thanks for Mutton, you’ll want to take some time and think about what you want the site to be about, and what’s the best way to organize it before you start adding categories. This way, you can set up a category structure that fits your content well so you’re not always scrambling to figure out what bucket a post belongs in, and you (or your authors) are not always creating new categories every time a new post goes up on the site.

Image

Category Magnets

Image

Use the magnets below to build a category structure for Thanks for Mutton. You don’t have to use all the magnets, and remember to think about big, broad bucket for your content.

Image
Image

Category Magnets

Image

Use the magnets below to build a category structure for Thanks for Mutton. You don’t have to use all the magnets, and remember to think about big, broad bucket for your content.

Image
Image

Leftover categories often make good tags

Don’t worry if you have categories left over—that’s a good thing! This usually means that the remaining categories are too narrow and might be better used as what are called “tags” within a post. Tags are specific terms that give more detail about the content of the post—a post about sous vide cooking might be in the “Techniques” category and have tags like “sous vide” and “meat.” A good rule of thumb is that a post should have a single category and one or more tags. Use tags to add detail once you’ve placed your post in a larger category bucket.

Image

Posts should have a single category and one or more tags.

Fireside Chats

Image

Tonight’s talk: Categories and Tags sound off about who offers the most information to site visitors.

Categories:

Tags:

I’d just like to start by saying that I’m the original taxonomy. I was around before tags were even a twinkle in WordPress’s eye. In fact, the original tagging structure in WordPress was built on top of the category system.

 

 

Just because you’ve been around longer doesn’t mean you’re better. You are too broad, you give people no in-depth information about an article. Big “buckets.” What’s that all about?

Oh, come on—broad topics are the only way to go. A site visitor can take one quick look at a category list and know exactly what kind of content is on a site or page. Tags only give me information when I click on a post and scroll all the way to the bottom. Plus, everyone understands categories—you always have to explain yourself to people.

 

 

Obviously you’ve never heard of a tag cloud. You can put it right on the home page and it gives you WAY more information then a list of categories. It shows what are the most popular topics on the site. Popular stuff, that’s what people want. Plus, it’s not enough to say this post is about design—you need to tell them what kind of design.

Oh, here we go with the tag cloud argument. You know, if I wanted to I could display myself as a tag cloud. Plus, what year is it—2007? Tag clouds, pssh...

 

 

Well, why don’t you then? I’m sure your users would appreciate it. And don’t think my only trick is the tag cloud. I’ve seen users do pretty cool things with bar graphs and all sorts of other cool visuals based on tags.

Well, if I’m used properly there shouldn’t be that many of me. It’s kind of hard to make a tag cloud out of 5 categories. Let’s just agree that we do different things. You handle the details and I take care of the big picture. You can’t have a blog without categories! Can you?...

 

 

Whoa. You sound a little nervous—like you think you may be obsolete. Personally, I think you are useful when used correctly, but most people abuse your power. Have you ever been to a site with hundreds of categories? It’s overkill and it just makes you look like you can’t focus.

Agreed... A compromise then. I’ll take care of the “big picture” and you can deal with all the little details. I don’t want to do that stuff anyway. Oh, you can also keep the tag cloud—I’m old-school like that.

 

 

All right, that sounds like a plan to me.

Writers want their pictures next to their posts

Now that we have some organization to Thanks for Mutton, the writers are starting to ask for more features. They’d like to know if you can add their images to posts, and to comments that they make on posts. They’ve noticed this on other sites and think it would be a good idea to put faces to names on the blog.

Image
Image
Image

Gravatar makes user pictures easy

Gravatar is a service by Automattic—the same folks that maintain WordPress. It stores “avatar,” or profile, images tied to an email address on its servers so websites around the Internet can use those images to display the avatar of users logged in to their sites. The idea is that you can upload an image once and use it across any site that supports Gravatar.

Image
Image
Image
Image

Gravatar works with your email address

Gravatar works by linking your email address to an avatar image that’s stored on the Gravatar servers. When an application or website that uses the Gravatar service wants to display your picture, it sends an encrypted version of your email to Gravatar along with information like file size and type. Gravatar then sends back a picture of your pretty face, auto-magically!

Image
Image

Gravatar supports WordPress comments out-of-the-box

Gravatar is baked right into WordPress (it helps that they’re run by the same company) and only takes a few settings to get it up and running on your blog.

Image Check the Gravatar setting in the Discussion menu.

All your options for modifying Gravatar are located at the bottom of the Discussion menu. You can choose to display avatars, what “rating” you’ll allow, and how the default icon looks if a user doesn’t have Gravatar.

Image

Image Save and Check

Once you save your avatar settings, go back to the dashboard and see if the new images are showing up.

Image

Extending Gravatar’s functionality

Image

So it turns out that Gravatar was intended only to support showing images next to comments. To get it working with our author’s posts, let’s investigate what makes Gravatar work in our comment template and see if we can’t use the same code to get avatars showing up in our main post bylines. Often a little detective work like this will help you figure out how to extend certain built-in functionality to other areas of your blog.

functions.php

Image

BRAIN BARBELL

Image

<?php echo get_avatar( $comment, 40 ); ?>

This is a PHP function that gets our Gravatar image for WordPress. We can give it a size and it will display an image next to the comment. Do you know which file we should add this to in order to get images next to the authors’ names on their post?

BRAIN BARBELL SOLUTION

Image
Image
Image

Image Ready Bake Code

As you’re already starting to figure out, anytime we make a change to our template markup (HTML) we need to make an associated style (CSS) change. Let’s add some style rules to make the authors’ pictures fit a bit better.

Image
Image
Image

Your WordPress Toolbox

Image

You’ve got Chapter 4 under your belt and now you’ve added user accounts, categories and tags, and avatar images to your tool box. Next up, adding video to your blog.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required