jquery sliderpro
・Official
http://bqworks.com/slider-pro/
・view
<?php if(is_home()): ?> <div id="mainvisual"> <div class="sp-slides"> <?php $custom_header_defaults = get_uploaded_header_images(); if ($custom_header_defaults): ?> <?php foreach ($custom_header_defaults as $key => $value): ?> <div class="sp-slide"> <img class="img-responsive" src="<?php echo $value['url']; ?>"> </div> <?php endforeach; else: ?> <img class="img-responsive" src="<?php echo get_custom_header()->url; ?>" height="<?php get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt=""> <?php endif; ?> </div> </div> <?php endif; ?>
・script.js
$(function(){ $(document).ready(function(){ $('#mainvisual' ).sliderPro({ width: "100%", aspectRatio: 2, arrows: true, buttons: true, autoplay: true, loop: true, visibleSize: '100%', forceSize: 'fullWidth' }); }); });
・functions.php
function add_styles() { if(!is_admin()) { // slider-pro if(is_front_page()) { wp_enqueue_style('slider-pro', get_template_directory_uri() . '/dist/css/slider-pro.min.css', false, 'all'); } } } add_action('wp_print_styles', 'add_styles'); function add_footer_script(){ if(!is_admin()) { wp_enqueue_script('sliderPro', get_template_directory_uri() . '/dist/js/jquery.sliderPro.min.js', array() , false, true); } } add_action('wp_print_scripts' , 'add_footer_script');