Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function areview_carousel_scripts() {
  5. if ( is_home() && get_theme_mod('carousel_display') ) {
  6.  
  7. wp_enqueue_script( 'areview-carousel', get_template_directory_uri() . '/inc/carousel/owl.carousel.min.js', array( 'jquery' ), true );
  8.  
  9. wp_enqueue_script( 'areview-carousel-init', get_template_directory_uri() . '/js/carousel-init.js', array(), true );
  10.  
  11. wp_enqueue_style( 'areview-carousel-style', get_template_directory_uri() . '/inc/carousel/owl.carousel.css' );
  12.  
  13. //carousel speed options
  14. if ( get_theme_mod('slideshowspeed') != '') {
  15. $slideshowspeed = 500;
  16. } else {
  17. $slideshowspeed = absint(get_theme_mod('slideshowspeed'));
  18. }
  19. $carousel_options = array(
  20. 'slideshowspeed' => $slideshowspeed,
  21. );
  22. wp_localize_script('areview-carousel-init', 'carouselOptions', $carousel_options);
  23. }
  24. }
  25. add_action( 'wp_enqueue_scripts', 'areview_carousel_scripts' );
  26.  
  27. function areview_carousel_template() {
  28. $cat = absint(get_theme_mod('carousel_cat'));
  29. if (get_theme_mod('carousel_number')) {
  30. $number = absint(get_theme_mod('carousel_number'));
  31. } else {
  32. $number = 12;
  33. }
  34. $args = array(
  35. 'posts_per_page' => $number,
  36. 'cat' => $cat
  37. );
  38. $query = new WP_Query( $args );
  39.  
  40. if ( $query->have_posts() ) {
  41.  
  42. ?>
  43. <?php global $cfs; ?>
  44. <div class="carousel-wrapper">
  45. <div class="carousel container">
  46. <?php while ( $query->have_posts() ) : $query->the_post(); ?>
  47. <div class="carousel-block">
  48. <?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') ) {
  49. echo do_shortcode('[yasr_overall_rating]');
  50. } ?>
  51. <?php if ( has_post_thumbnail() ) : ?>
  52. <div class="carousel-thumb">
  53. <a href="<?php the_permalink(); ?>">
  54. <?php the_post_thumbnail('carousel-thumb'); ?>
  55. </a>
  56. </div>
  57. <?php endif; ?>
  58. </div>
  59. <?php endwhile; ?>
  60. </div>
  61. <div class="decoration-bar"></div>
  62. </div>
  63. <?php }
  64.  
  65. wp_reset_postdata();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement