<!--
TO Display product
BY Sunny Soni
-->
<ul class="products">
<?php
// $args = array( 'post_type' => 'product', 'posts_per_page' => 4,'order' => 'DESC' );
$args = array( 'post_type' => 'product','posts_per_page' => $a ,'meta_key' => '_featured', 'meta_value' => 'yes', 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<li class="producthome">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>">
<div class="thumbnail">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />'; ?>
<div class="thumb-shadow"></div>
<strong class="below-thumb"><?php the_title(); ?></strong>
</div>
<span class="price"><?php echo $product->get_price_html(); ?></span>
</a>
<div class="buttons">
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
</div>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
<!-------- --->
<!--
TO Display all the products
BY Sunny Soni
-->
<ul class="products">
<?php $args = array( 'post_type' => 'product', 'posts_per_page' => 4, 'order' => 'DESC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<li class="producthome">
<a href="<?php the_permalink(); ?>">
<div class="thumbnail">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />'; ?>
<div class="thumb-shadow"></div>
<strong class="below-thumb"><?php the_title(); ?></strong>
</div>
<span class="price"><?php echo $product->get_price_html(); ?></span>
</a>
<div class="buttons">
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
<a href="<?php the_permalink(); ?>">Detail</a>
</div>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
<!--
To Display All Featured Product
BY Sunny Soni
-->
<ul class="products">
<?php $args = array( 'post_type' => 'product','posts_per_page' => 4 ,'meta_key' => '_featured','meta_value' => 'yes', 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<div class="producthome">
<a href="<?php the_permalink(); ?>">
<div class="thumbnail">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />'; ?>
<div class="thumb-shadow"></div>
<strong class="below-thumb"><?php the_title(); ?></strong>
</div>
<span class="price"><?php echo $product->get_price_html(); ?></span>
</a>
<div class="buttons">
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
<a href="<?php the_permalink(); ?>">Detail</a>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
<!--
To Display SALE Product
BY Sunny Soni
-->
<ul class="products">
<?php $args = array( 'post_type' => 'product','posts_per_page' => 4 ,'product_cat' => 'sale', 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<div class="producthome">
<a href="<?php the_permalink(); ?>">
<div class="thumbnail">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />'; ?>
<div class="thumb-shadow"></div>
<strong class="below-thumb"><?php the_title(); ?></strong>
</div>
<span class="price"><?php echo $product->get_price_html(); ?></span>
</a>
<div class="buttons">
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
<a href="<?php the_permalink(); ?>">Detail</a>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
No comments:
Post a Comment