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
//	Custom featured products
	function viroshop_featured_products( $atts ) {

		extract(shortcode_atts(array(
			'title' 	=> 'Featured Items',
			'per_page' 	=> '4',
			'columns' 	=> '4',
			'orderby' => 'date',
			'order' => 'desc'
		), $atts));
		global $secondloop;
		$args = array( 'post_type' => 'product', 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'meta_key' => '_featured', 'meta_value' => 'yes' );
		$secondloop = new WP_Query( $args );
		if ( is_user_logged_in() ) {
		if ($secondloop->have_posts()) :
			$list = '	<div id="carousel" class="es-carousel-wrapper">
						<span class="slide-title">'. $title .'</span>
						<div class="es-carousel">
							<ul>';				
							while ( $secondloop->have_posts() ) : $secondloop->the_post(); global $product, $woocommerce;
								$list .= '<li><a href="' . get_permalink() . '">';
								if (has_post_thumbnail( $loop->post->ID )) {
									$list .= ''. get_the_post_thumbnail($secondloop->post->ID, 'shop_feature_catalog',array('title' => "")) .'</a></li>';	
								} else {
									$list .= '<img src="'.get_template_directory_uri().'/images/featured-placeholder.jpg" alt="Placeholder" width="145px" height="auto" />';
								}
							endwhile;
							wp_reset_query();
							return $list . 
						'</ul>
						</div>
				</div>';
		 endif;
		 }
	}
add_shortcode('vs_featured_products', 'viroshop_featured_products');