Home › Forums › ACF PRO › Get Jquery from Advanced Custom Fields value › Reply To: Get Jquery from Advanced Custom Fields value
In case it is option page
<script>
var testVar = "<?=get_field('field_name','option'); ?>";
</script>
In case it is CPT:
<script>
var testVar = "<?=get_field('field_name',$post_id); ?>";
</script>
So, now you can use testVar in your jQuery after loading page
Trick:
store php & MySql value in hidden inputs with known id and then get this input value by its id in your jQUery code
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.