Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- https://docs.woocommerce.com/document/woocommerce-shortcodes/
- https://stackoverflow.com/questions/42765910/how-can-i-list-best-selling-products-in-woocommerce
- <?php
- $args = array(
- 'post_type' => 'product',
- 'meta_key' => 'total_sales',
- 'orderby' => 'meta_value_num',
- 'posts_per_page' => 1,
- );
- $loop = new WP_Query( $args );
- while ( $loop->have_posts() ) : $loop->the_post();
- global $product; ?>
- <div>
- <a href="<?php the_permalink(); ?>" id="id-<?php the_id(); ?>" title="<?php the_title(); ?>">
- <?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="product placeholder Image" width="65px" height="115px" />'; ?>
- <h3><?php the_title(); ?></h3>
- </a>
- </div>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement