How to show custom fields in divi blog module?
Asked Answered
E

2

6

Theme: Divi
Plugin for custom fields in post: ACF - Advanced Custom Fields

Using the Divi Blog module in Grid mode, I want to show a custom field (registered using the ACF plugin) alongside the post title, author, excerpt, post date, etc.

See the blue line in the screenshot to give you an idea.

enter image description here

Is there a way to have the Divi Blog module display a ACF field? Perhaps a editing the module function?

Thanks in advance

Erewhile answered 5/4, 2018 at 6:12 Comment(4)
Please help me .Erewhile
You can add short code in content.Rerun
Is there any other way .. I mean editing any template ?Erewhile
There are a few articles on how to customise Divi modules. This is a good one.Nitrometer
S
3

Just did this successfully.

  1. You first have to move the Blog module into your child theme using these instructions: https://intercom.help/elegantthemes/en/articles/4532734-moving-blog-module-in-child-theme
  2. In your new, child theme Blog.php file, find the section that starts with the comment "Filters Blog module's main query." For some reason there were what appeared to be two of this entire section in my file so make sure you're editing the last instance of this.
  3. Add your field values in the list right under the last one listed - it should be $thumb. My field in the example below is $start_date.
    $thumb     = $thumbnail['thumb'];
    $start_date = get_field('start_date');
  1. Scroll down and find the place where you want to add your field within the article. (For example, I searched for 'class="entry-title"' in order to place my field below that.) Use some version of the following that works for the placement required.
<?php if($start_date) { ?>
    <div class="start_date"><?php the_field('start_date'); ?></div>
<?php } ?>
Straightforward answered 14/12, 2022 at 20:59 Comment(1)
Great solution!Heptane
L
-2

Divi provides an option to include Dynamic Content into Divi Builder. Not sure whether this works for the DIVI Blog Grid layout. Just give it a try and see if it works for you.

https://www.elegantthemes.com/blog/theme-releases/dynamic-content-for-divi-is-available-now

Lanford answered 12/2, 2020 at 6:27 Comment(1)
It doesn't work. This should be a comment, not an answer.Antagonistic

© 2022 - 2024 — McMap. All rights reserved.