One of the current limitations of Elementor’s recent posts widget is that it can’t pull custom fields. It does, however, pull in an excerpt. This little “hack” below is an example of sending Advanced Custom Fields into the excerpt so they can be exposed in the Elementor posts widget. In this example, the post type is “Claim” and the fields are “reduced_price” and “list_price”. This would go in your theme’s functions.php file:
add_filter('get_the_excerpt', 'custom_claim_excerpt');
function custom_claim_excerpt( $excerpt ) {
if ( 'claim' == get_post_type() ) {
$output = '';
if (get_field('reduced_price')) {
$output .= '<span style="text-decoration:line-through;">$' . get_field('list_price') . '</span> <span>$' . get_field('reduced_price') . '</span>';
}
else {
$output .= '<span>$' . get_field('list_price') . '</span>';
}
return $output;
}
}