How do I add a custom body class for a specific page ID?

The ID can/should be given without quotes (otherwise if you a page with ‘38034’ as slug/post_name, this will be used instead of the page with the ID 38034). And you want to return $classes no matter if you added your own or not. add_filter(‘body_class’, ‘custom_body_class’); function custom_body_class($classes) { if (is_page(38034)) $classes[] = ‘new-class’; return $classes; … Read more

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 … Read more