1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function recent_products_slider_func($atts) {
		global $woocommerce_loop;
		static $count = 0;
  		if (empty($atts)) return;
  
		extract(shortcode_atts(array(
			'title'			=> 'NEW PRODUCTS',
			'order' 		=> 'DESC',
			'orderby' 		=> 'date',
			'mousewheel' 	=> 'false',
			'autoscroll' 	=> 'false',
			'swipe' 		=> 'false',
			'scroll' 		=> '1',
			'items' 		=> 6
		), $atts));
	
		$args = array(
			'post_type'	=> 'product',
			'post_status' => 'publish',
			'posts_per_page' => $items,
			'ignore_sticky_posts'	=> 1,
			'orderby' => $orderby,
			'order' => $order,
			'meta_query' => array(
				array(
					'key' 		=> '_visibility',
					'value' 	=> array('catalog', 'visible'),
					'compare' 	=> 'IN'
				)
			)
		);
	
		ob_start();
	
		$products = new WP_Query( $args );


		if ( $products->have_posts() ) : ?>
			<script>
				jQuery(document).ready(function($) {
					$(function() {
						$('.<?php echo $count; ?>.carousel-products ul').carouFredSel({		
							mousewheel: <?php echo $mousewheel; ?>,
							prev: '.<?php echo $count; ?>.prev',
							next: '.<?php echo $count; ?>.next',						
							scroll		: {
								items			: <?php echo $scroll; ?>,
								pauseOnHover	: true	
							},	
							auto: <?php echo $autoscroll; ?>,
							swipe: {
								onMouse: <?php echo $swipe; ?>,
								onTouch: <?php echo $swipe; ?>
							}
						});
					});
				});
			</script>
		
			<div class="carousel-products <?php echo $count; ?>">
				<h4><?php echo $title; ?></h4>	
				<div class="carousel-nav">
					<a class="icon-left-open prev <?php echo $count; ?>" href="#"></a>
					<a class="icon-right-open next <?php echo $count; ?>" href="#"></a>
				</div>
		
				<ul class="slide-products">		
					<?php while ( $products->have_posts() ) : $products->the_post(); ?>	

						<?php if ( class_exists('woocommerce') ) {  woocommerce_get_template_part( 'content', 'product' ); } ?>
					<?php endwhile; ?>				
				</ul>
			</div>
		
		<?php endif; 

		wp_reset_query();       
	    $count++;                  
	
		return ob_get_clean();
}                  
add_shortcode('recent_products_slider', 'recent_products_slider_func');