• Hi,

    I would like to use a PHP Array, that I’m retrieving in the WP-Loop into a javascript function, that I’m having in a separate js-file.

    That’s how I’m echoing my php array (from Advanced Custom Fields) in the loop:

    $images = get_field('galerie');
        if( $images ): ?>
            <?php 
            $i = 0;
            foreach( $images as $image ): 
                $i++;
                ?>
                <div class="slider">
                     <?php echo $image['url']; ?>');">
                </div>
            <?php endforeach; ?>
        <?php endif; ?>

    In the final code this would look like:

    <div class="slider">
       THERE_GOES_THE_IMG_URL_1
       THERE_GOES_THE_IMG_URL_2
       THERE_GOES_THE_IMG_URL_3
    </div>

    But I need to use the Image URLs in my Vegas Slider JQuery Plugin. The code is in a separate custom.js file and looks like this:

    $(".slider").vegas({
          slides: [
              { src: "THERE_GOES_THE_IMG_URL_1" },
              { src: "THERE_GOES_THE_IMG_URL_2" },
              { src: "THERE_GOES_THE_IMG_URL_3" }
          ]
      });

    How can I pass the Image URLs from the php loop into the jQuery Plugin?

    Thanks for your help!
    Cara

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Getting an php Array from ?Advanced Custom Fields Plugin? into Js-Function’ is closed to new replies.