Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've inherited a theme from a another developer that I've re-styled for a client. We're just about finished, but I thought I'd run it through the Theme-Check plug-in to see if there's any errors or problems.

Unfortunately there's a ton. I've gotten rid of most of them, but I have one Required left:

REQUIRED: Could not find post_class. See: post_class

I've read the WP page on post_class, but as a relative newcomer I still don't understand what it is, or why it should be required.

What should I do to fix this?

share|improve this question
    
If the Theme isn't intended for public distribution, then many of the required components of Theme Check will not apply. The post_class() requirement is one of them. –  Chip Bennett Mar 21 '13 at 17:18
    
@ChipBennett Thanks, Chip. I'll bear that in mind. Probably good practice if the client adds plug-ins themselves in the future, though :) –  Django Reinhardt Mar 21 '13 at 18:04
add comment

1 Answer

up vote 3 down vote accepted

What it does

post_class adds classes to the posts on a post by post basis, usually adding them to some kind of post "wrapper". This allows for the targeting of posts with CSS rules according to various criteria-- category, tag, sticky, format, etc. That is, theme authors, plugin authors, and individual users can write CSS rules based on the classes added by post_class and get very fine grained control over layout.

Why you want it

While I am not a canonical source, I am sure it is required according to the WordPress Theme guidelines to ensure a minimal functionality across themes. If you aren't submitting your theme to the WordPress repo you can do what you want. There are no WordPress Theme Police to track you down and spank you, but post_class and the related body_class are very useful and easy to implement. I see no reason not to use them.

share|improve this answer
    
Thanks very much! That helps a lot. In my case, though, there's no different styles for different posts, so I suppose it's not very much use to me? –  Django Reinhardt Mar 21 '13 at 14:22
    
There may be no styling for posts right now, but you don't know about later, and you don't know what a plugin might try to do. It is reasonable for a plugin to depend upon officially required functionality. –  s_ha_dum Mar 21 '13 at 14:43
    
Yes, you're right. I'm going to add it. –  Django Reinhardt Mar 21 '13 at 14:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.