110 PART II • Designing and Developing WordPress Themes
comment. That means that the post author needs to be logged in when commenting; other-
wise, WordPress won’t recognize him or her.
You can give the post author comments a yellow background by adding this to style.css:
li.bypostauthor { background: yellow; }
You may want do something fancier as well, but changing the background of the comment is a
good idea, as is upping the font size and/or color a bit. And if you want to, you can take it really far
because everything related to the particular comment is found within the li.bypostauthor
tag. This means that you can change the way the avatar is displayed (img.avatar is the CSS
class you’re looking for) or alter the comment metadata (div.comment-author and div.
comment-meta) as well as the actual comment text. Set the comment text font size to 18 pixels,
just for the fun of it, and keep the comment background yellow:
li.bypostauthor { background: yellow; }
li.bypostauthor div.comment-body p { font-size: 18px; }
Use post author highlighting with caution. After all, it is not always all that important that the
post author’s comments are highlighted this way. A smaller note, however, will never hurt.
ADDING CUSTOM FIELDS
Custom fields open up even more advanced options to the theme and plugin designer. They
provide a way to store custom data in the database, and that in turn means that they can open
up new functionality. See the “Using Custom Fields” section in Chapter 6 for hands-on examples
of how custom fields work; in this section, I explain what you can do with them as a designer.
COMMON USAGE
Custom fields were initially thought of as a way to store metadata for a post, and that’s still the
way they are presented in the Codex, as well as how the default output (which you’ll get to)
behaves. However, that is not the most common usage for custom fields these days. Most
often, custom fields are used to attach a reference of an image to a post and use it in listings or
to achieve what is often referred to as magazine-style headlines. However, custom fields
needn’t be limited to managing magazine-style headlines or showing off alternative post
thumbnails in listings. You can use custom fields for a number of things, such as applying
custom CSS styles depending on the post as a way to add further unique styling to posts. Or
you can use custom fields to create and identify a series of posts (the key would be Series,
and the value would be the various series’ names) and then create a Page template with a
custom loop that limits the output to posts with a specific Series value.
Another image-based custom field implementation would be to not only apply headline and
listing images for the post, but also alter the complete body background!
Custom fields can be taken pretty far, so whenever you need to step outside the boundaries of
traditional WordPress template tags and functions, custom fields are definitely worth a look.