Answer the question
In order to leave comments, you need to log in
How to display woocommerce products on wp home page?
Hello guys,
what smart widgets / plugins do you know for displaying goods from wookomers on the main page, otherwise for some reason such a thing is not provided for in my theme, I would like to display 6-12 products with a tile.
Answer the question
In order to leave comments, you need to log in
I use this code to display popular products (those marked with an asterisk in the admin panel)
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_featured',
'meta_value' => 'yes',
'posts_per_page' => 2
);
$featured_query = new WP_Query( $args );
if ($featured_query->have_posts()) :
while ($featured_query->have_posts()) :
$featured_query->the_post();
$product = get_product( $featured_query->post->ID ); ?>
<li class="featured-products-item">
<a><?php the_post_thumbnail();?></a>
<?php the_excerpt();;?>
</li>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // Remember to reset
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question