This function shows my popup.
$('.call-hunt-btn').on('click', callHunt);
function callHunt(e) {
e.preventDefault();
$.arcticmodal({
type: 'ajax',
url: 'wp-content/themes/beton/modals/modal-feedback.php',
overlay: {
css: {
backgroundColor: '#000',
opacity: .75
}
},
afterOpen: function(){
setMaskPhone();
setDataSBJS('.arcticmodal-container');
}
});
}
It uses a php template. I want to use ACF fields in this template.
If I just write: <?php the_field('class'); ?>
, but nothing happens.
How do I fix it?
If you are adding your javascript via wp_enqueue_script() function, you could expose the ACF values via the wp_localize_script() function (https://codex.wordpress.org/Function_Reference/wp_localize_script).
The wp_localize_script() function creates a Javascript object based on the values set in the PHP array supplied to the wp_localize_script(). The ACF values can then be access from the Javascript object using dot notation.