WordPress.org

Ready to get started?Download WordPress

Forums

post_class() multiple values (3 posts)

  1. jasonsweb
    Member
    Posted 1 year ago #

    Hi,

    Is it possible to add two variables to the post_class()?

    At the moment I've got this:
    <?php post_class('custom-class ' . $var1 . $var2); ?>

    So one custom class and two variables. This is working, but it's putting the two classes of the variables together, without a space...
    Example:
    custom-class var1var2

    Is it possible to simply add a space?
    Thanks in advance!

  2. Jose Castaneda
    Member
    Posted 1 year ago #

    You could try
    'custom-class' . "$var1" . "$var2"
    Worth a shot, right?

  3. jasonsweb
    Member
    Posted 1 year ago #

    Thanks!
    Works like a charm. (I've added a space behind "var1 ").

Topic Closed

This topic has been closed to new replies.

About this Topic