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.

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:

post_class($even_odd);

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

Ideas?

share|improve this question
add comment

1 Answer

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");

Or

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! –  songdogtech Nov 5 '12 at 0:19
    
Variables don't 'expand' inside single quotes –  s_ha_dum Nov 5 '12 at 0:21
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.