Mailpoet send custom post type function

paolopiace

New member
XNullUser
Joined
Mar 20, 2025
Messages
2
Reaction score
0
Points
1
Location
italy
NullCash
38
replace custom field whith our fiel name


function CustomACFfilterContent($content, $post_id) {
$ref_code = get_field('ref_code', $post_id);
$job_title = get_field('job_title', $post_id);
$domicilio = get_field('domicilio', $post_id);
$ccnl = get_field('ccnl', $post_id);
$livello = get_field('livello', $post_id);
$ral = get_field('ral', $post_id);
$variabile = get_field('variabile', $post_id);
$benefit = get_field('benefit', $post_id);
$descrizione = get_field('descrizione', $post_id);
$table = '<table cellspacing="8" cellpadding="8" class="tabella_mailpoet" style="font-family: Arial; font-size: 16px; margin: 10px; padding: 10px;">
<tbody>
<tr>
<td style="min-width: 120px; font-weight: bold; margin-bottom: 12px;">Ref Code</td>
<td>' . $post_id . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">Job Title</td>
<td style="vertical-align: top; margin-bottom: 12px;">' . $job_title . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">Domicilio</td>
<td>' . $domicilio . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">CCNL</td>
<td>' . $ccnl . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">Livello</td>
<td>' . $livello . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">RAL</td>
<td>' . $ral . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">Variabile</td>
<td>' . $variabile . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; margin-bottom: 12px;">Benefit</td>
<td style="vertical-align: top; margin-bottom: 12px;">' . $benefit . '</td>
</tr>
<tr>
<td style="min-width: 30%; font-weight: bold; vertical-align: top; margin-bottom: 12px;">Descrizione</td>
<td style="vertical-align: top; margin-bottom: 12px;">' . $descrizione . '</td>
</tr>
</tbody>
</table>';
$table .= "<br>";
//$table .= "<a href='mailto:lead@studioassociato.it?subject=Richiesta informazioni annuncio Rif. ". $post_id ."'> btn richiedi info </a>";
$table .= " text " ;

$content .= '<div>'.$table.'</div>';
return $content;
}

add_filter('mailpoet_newsletter_shortcode', 'mailpoet_custom_shortcode', 10, 6);
function mailpoet_custom_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body, $arguments) {
// always return the shortcode if it doesn't match your own!
if ($shortcode !== '[custom:tabella]') return $shortcode;

$table = '';

// Get the latest Top Candidates
$args = array(
'post_type' => 'top_candidates',
'post_status' => 'publish',
'posts_per_page' => 1, // Use the specified number of posts
'orderby' => 'ID',
'order' => 'DESC'
);
$latest_posts = new WP_Query($args);
if ($latest_posts->have_posts()) {
$table = "<table border=0><tbody>";
while ($latest_posts->have_posts()) {
$latest_posts->the_post();
$id = get_the_ID();
$title = get_the_title();
$ref_code = get_field('ref_code', $id);
$job_title = get_field('job_title', $id);
$domicilio = get_field('domicilio', $id);
$ccnl = get_field('ccnl', $id);
$livello = get_field('livello', $id);
$ral = get_field('ral', $id);
$variabile = get_field('variabile', $id);
$benefit = get_field('benefit', $id);
$descrizione = get_field('descrizione', $id);
$table .= "<tr><td><strong>Codice riferimento</strong></td><td>".$ref_code."</td></tr>";
$table .= "<tr><td><b>Job Title</b></td><td>".$job_title."</td></tr>";
$table .= "<tr><td>Domicilio</td><td>".$domicilio."</td></tr>";
$table .= "<tr><td>CCNL</td><td>".$ccnl."</td></tr>";
$table .= "<tr><td>Livello</td><td>".$livello."</td></tr>";
$table .= "<tr><td>RAL</td><td>".$ral."</td></tr>";
$table .= "<tr><td>Variabile</td><td>".$variabile."</td></tr>";
$table .= "<tr><td>Benefit</td><td>".$benefit."</td></tr>";
$table .= "<tr><td>Descrizione</td><td>".$descrizione."</td></tr>";
}
$table .= "</tbody></table>";
}
return $table;
}
 
Top