Home › Forums › Gutenberg › Add script with ACF fields to footer within custom block › Reply To: Add script with ACF fields to footer within custom block
Hi @hube2 , thanks for the help.
Your first comment unfortunately didn’t work – same results as before. For the wp_add_inline_script option, how do I add my php into that script?
The following code causes issues because I’m trying to put PHP in a JavaScript string (the $data parameter of wp_add_inline_script), I think:
<?php
wp_add_inline_script('swiper', '
var swiper = new Swiper(".swiper", {
slidesPerView: <?php the_field("slides_per_view"); ?>
});
')
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.