I'm developing a module to send mails from a WordPress post, using some custom fields from ACF.
I have an initial structure like:
$to = $wpp_send_status_email;
$subject = $wpp_send_status_subject;
$body = "
<html>
<table border='0' cellpadding='0' cellspacing='0' style='background: #fff; max-width:670px;margin:40px auto;text-align:left;color:#000;border: 1.3px solid rgba(0, 0, 0, 0.05);-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;-webkit-box-shadow: 0px 5px 15px -10px rgba(0, 0, 0, 0.2); box-shadow: 0px 5px 15px -10px rgba(0, 0, 0, 0.2)'>
The code works okay, but when I have to use the repeater field with if and else options, I don't have success. My original code is:
<?php if(get_field('to-do')): ?>
<tbody>
<tr>
<th style="font-family:Arial,sans-serif;text-align: left; vertical-align: middle; padding: 0 0 20px 0; font-size: 14px">Tarefa</th>
<th style="font-family:Arial,sans-serif;text-align: left; vertical-align: middle; padding: 0 0 20px 0; font-size: 14px">Deadline</th>
<th style="font-family:Arial,sans-serif;text-align: left; vertical-align: middle; padding: 0 0 20px 0; font-size: 14px">Status</th>
</tr>
<?php while(has_sub_field('to-do')): ?>
<tr style="border-top: 1px solid rgba(0, 0, 0, 0.05)">
<td class="timeline-phase-activity ng-scope" style="text-align: left;vertical-align:middle;font-size:14px;width:60%;font-family:Arial,sans-serif;padding:10px 30px 10px 0"><span><?php the_sub_field('task-name'); ?></span></td>
<td style="vertical-align:middle;text-align:left;padding-left: 24px;font-size:14px;font-family:Arial,sans-serif;padding:10px 0">
<span style="padding-right:1.125rem"><?php the_sub_field('deadline'); ?></span>
</td>
<td style="text-align:left;vertical-align:middle;font-size:14px;font-family:Arial,sans-serif;;padding:10px 0"><span><?php the_sub_field('status'); ?></span>
</td>
</tr>
<?php endwhile; ?>
</tbody>
<?php endif; ?>
Does anyone know how I include this inside HTML tag? My other field is on the " . get_field('conclusion', $post->ID) . " structure, but this doesn't work with if and else.
get_sub_field()
doesn't work like that outside of ahave_rows()
→the_row()
context. How is your repeater field structured, anyway? Refer to the documentation: advancedcustomfields.com/resources/get_sub_field – Damocles