WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This must be pretty simple, but it is eluding me. I need to add several classes to post_class() http://codex.wordpress.org/Function_Reference/post_class

I can add one class in a page template, as below:


but I need to add several more, i.e. $current_post and $current_in_total

They won't echo, and they won't output this way: post_class($current_post; $even_odd; $current_in_total;)

I need to output these in a page template using post_class(), not add them via a hook in functions.php


share|improve this question
up vote 2 down vote accepted

Multiple post classes should be separated by a single space or should be in an array.

post_class("$even_odd $current_post $current_in_total");


post_class(array($even_odd, $current_post, $current_in_total));

share|improve this answer
Ah, I was using single quotes. The first example works fine. Thanks! – markratledge Nov 5 '12 at 0:19
Variables don't 'expand' inside single quotes – s_ha_dum Nov 5 '12 at 0:21

Your Answer


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.