How to add classes to post_class?

The post_class function does also accept an array of classes. You can pass them to the function as follows:

$classes = [
    'card',
    'grid-item',
    'wow',
    'fadeInUp',
    $termsString
];

<div <?php post_class ( $classes ); ?>>
   ...
</div>

You can store the custom field’s value inside a variable, and then pass it to the function just like any other value.

Leave a Comment