Skip to content

Instantly share code, notes, and snippets.

/Php
Created Feb 21, 2014

Embed
What would you like to do?
anything slider
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID,
'orderby' => 'menu_order ID',
);
$attachments = get_posts($args);
if ($attachments) {?>
<div id="slider" class="slider">
<?php
$i = 1;
foreach ($attachments as $attachment) {
//echo apply_filters('the_title', $attachment->post_title);
$image = wp_get_attachment_image_src( $attachment->ID, 'full' ); ?>
<div>
<img class="check" src="<?php echo get_template_directory_uri() ?>/js/timthumb.php?src=<?php echo $image[0] ?>&amp;w=610" />
</div>
<?php
$i++;
} ?>
<script type="text/javascript">
jQuery(document).ready(function($){
$('#slider').anythingSlider({
hashTags : false,
expand : true,
autoPlay : true,
resizeContents : false,
pauseOnHover : true,
buildArrows : false,
buildNavigation : false,
delay : <?php echo $data['pausetime'] ?>,
resumeDelay : 0,
animationTime : <?php echo $data['anispeed'] ?>,
delayBeforeAnimate:0,
easing : 'easeInOutQuint',
onSlideBegin : function(e, slider) {
$('.nextbutton').fadeOut();
$('.prevbutton').fadeOut();
},
onSlideComplete : function(slider) {
$('.nextbutton').fadeIn();
$('.prevbutton').fadeIn();
}
})
$('.blogsingleimage').hover(function() {
$(".slideforward").stop(true, true).fadeIn();
$(".slidebackward").stop(true, true).fadeIn();
}, function() {
$(".slideforward").fadeOut();
$(".slidebackward").fadeOut();
});
$(".pauseButton").toggle(function(){
$(this).attr("class", "playButton");
$('#slider').data('AnythingSlider').startStop(false); // stops the slideshow
},function(){
$(this).attr("class", "pauseButton");
$('#slider').data('AnythingSlider').startStop(true); // start the slideshow
});
$(".slideforward").click(function(){
$('#slider').data('AnythingSlider').goForward();
});
$(".slidebackward").click(function(){
$('#slider').data('AnythingSlider').goBack();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.