Home › Forums › General Issues › Gallery slider problem
Hi,
I have a flexslider there shows images from gallery field and i works perfect.
But the javascript to the slider ruin all the other javascript functions on the page where the slider is, are there someone there who has an idea for a solution.
The code:
<?php
$images = get_field('gallery');
if( $images ): ?>
<div id="slider" class="flexslider">
<ul class="slides">
<?php foreach( $images as $image ): ?>
<li>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<p><?php echo $image['caption']; ?></p>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.min.js">\x3C/script>')</script>
<!-- FlexSlider -->
<script defer src="js/jquery.flexslider.js"></script>
<script type="text/javascript">
$(function(){
SyntaxHighlighter.all();
});
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
start: function(slider){
$('body').removeClass('loading');
}
});
});
</script>
Thank you
//Asger
Hello Asger,
functions is the best place to call all scripts(javascripts) and styles.
Syntax highlighting is not necessary in real life project.
The code below is enough to make flexslider work.
<script type="text/javascript">
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
});
});
</script>
Please, make sure that you have added call to flexslider.css and place flexslider’s font in proper place as well.
Hello Rajat,
thanks for your reply
I have solved my problem with the help from this video –> https://www.youtube.com/watch?v=voOQDohL4Pc
//Asger
The topic ‘Gallery slider problem’ is closed to new replies.
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.