Home › Forums › General Issues › Add Field Values to WordPress post_class › Reply To: Add Field Values to WordPress post_class
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 :
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.