Last active
December 17, 2015 11:09
-
-
Save zoerooney/5600583 to your computer and use it in GitHub Desktop.
UnoSlider (http://unoslider.npmedia.net/) + WordPress Slider Tutorial Code [Tutorial Coming Soon]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ENQUEUE SCRIPTS | |
*/ | |
function add_new_scripts_method() { | |
if ( is_page_template('page-with-slider.php') ) : | |
wp_enqueue_script( | |
'unoslider', | |
get_template_directory_uri() . '/js/unoSlider-1.0.1.min.js', | |
array('jquery') | |
); | |
endif; | |
} | |
add_action('wp_enqueue_scripts', 'add_new_scripts_method'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
if ( $('#slider ul li').length > 1 ) { | |
$('#slider').unoSlider({ | |
auto: false, | |
next: '#slider-next', | |
prev: '#slider-prev' | |
}); | |
} else { | |
$('#slider').unoSlider({ | |
auto: false | |
}); | |
$('#slider-next, #slider-prev').hide(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// full file coming soon... | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$images = get_field('slider_images'); | |
if( $images ): ?> | |
<div id="slider"> | |
<ul> | |
<?php foreach( $images as $image ): ?> | |
<li> | |
<?php if ( $image['description'] != '' ) : ?> | |
<a href="<?php echo $image['description']; ?>"> | |
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> | |
</a> | |
<?php else : ?> | |
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> | |
<?php endif; ?> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
<a href="#" id="slider-prev">Previous</a> | |
<a href="#" id="slider-next">Next</a> | |
</div><!-- #slider --> | |
<?php endif; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Slider */ | |
.unoSlider,.unoSlider ul,.unoSlider .sliderView { | |
width:1000px; | |
} | |
.unoSlider ul,.unoSlider .sliderView { | |
min-height:400px; | |
} | |
.unoSlider ul { | |
list-style:none; | |
margin: 0; | |
padding: 0; | |
overflow:hidden; | |
position:relative; | |
} | |
.unoSlider .sliderView{left:1000px;opacity:0;position:absolute;top:0;z-index:1} | |
.unoSlider .sliderView.current{left:0;opacity:1;z-index:10} | |
#slider-next, | |
#slider-prev { | |
width: 37px; | |
height: 85px; | |
display: inline-block; | |
text-indent: -9999em; | |
position: absolute; | |
top: 150px; | |
z-index: 10; | |
} | |
#slider-prev { | |
background: url('images/slider-prev.png') no-repeat; | |
left: 10px; | |
} | |
#slider-next { | |
background: url('images/slider-next.png') no-repeat; | |
right: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@decodigo I did not, still in my drafts folder. Also I guess I don't get comment notifications from Gists...