Support

Account

Home Forums Front-end Issues How to use the_field() data inside javascript Reply To: How to use the_field() data inside javascript

  • Thank you for your reply.

    I went back and looked at all the code again and I can’t figure out what I was doing wrong before. When I did as your suggested (which I thought I had already tried) then this time it did work! Weird. In case any one else wants to know, this is what worked:

    <script type="application/ld+json">
         {
          "@context": "http://schema.org/",
          "@type": "Recipe",
          "name": "<?php the_field('recipe_name'); ?>",
          "image": "http://images.media-allrecipes.com/userphotos/600x600/1116471.jpg",
          "author": {
          "@type": "Person",
          "name": "scoopnana"
         }
         }
    </script>

    Thank you. Please mark as resolved.