Home › Forums › General Issues › Add Field Values to WordPress post_class › Reply To: Add Field Values to WordPress post_class
Hi there,
Looks like you’ll need to use a child theme here.
If you modify directly your theme, your modifications will be suppressed when you’ll update your theme.
You’re lucky! The Divi Elegant Theme documentation is well done for that :
https://www.elegantthemes.com/blog/divi-resources/divi-child-theme
Just follow the instructions to overwrite properly your blog.php template.
Then you could add your custom field value to post_class() with acf function “the_field()”.
Your modified blog.php template will probably look like this :
<article id=”post-<?php the_ID(); ?>” <?php post_class(‘et_pb_post clearfix’ . $no_thumb_class . $overlay_class . the_field(‘your_field_name’) ); ?>>
You can also check the WordPress documentation about the post_class() function: https://developer.wordpress.org/reference/functions/post_class/
Hope it helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.