Woocommerce Top Rated Products

<h2 class=”head”>Top Rated Products</h2>

<?php
global $woocommerce_loop;

$meta_query = WC()->query->get_meta_query();
//print_r($meta_query);
$args = array(
‘post_type’ => ‘product’,
‘post_status’ => ‘publish’,
‘ignore_sticky_posts’ => 1,
‘orderby’ => ‘title’,
‘posts_per_page’ => ‘3’,
‘meta_query’ => $meta_query
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
//$i=0;
while ( $loop->have_posts() ) : $loop->the_post();
//print_r($loop->post);
global $product;
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($loop->post->ID, array(600,400) ));
$price = get_post_meta( $loop->post->ID, ‘_regular_price’, true);
$sale = get_post_meta( $loop->post->ID, ‘_sale_price’, true);
global $product;
?>

<a href=”<?php the_permalink(); ?>”>

<img src=”<?php echo $thumbnail[0]; ?>” alt=””/>
<
<p class=”title”><?php echo $loop->post->post_title;?></p>

<span class=”reducedfrom”><?php echo get_woocommerce_currency_symbol().$price; ?></span>
<span class=”actual”><?php echo get_woocommerce_currency_symbol().$sale; ?></span>

<?php
endwhile;
}
wp_reset_postdata();
?>

Advertisements

Published by

oudarya

I am a developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s