Last active
September 17, 2023 19:05
-
-
Save eliasfaical/da42edd298b0aa4d5a2a to your computer and use it in GitHub Desktop.
Sample products loop - Woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="products"> | |
<?php | |
$args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'camisa' ); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> | |
<h2>Shoes</h2> | |
<li class="product"> | |
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> | |
<?php | |
woocommerce_show_product_sale_flash( $post, $product ); | |
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="300px" height="300px" />'; | |
the_title( '<h3>', '</h3>' ); | |
echo '<span class="price">'. $product->get_price_html() .'</span>'; | |
?> | |
</a> | |
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?> | |
</li> | |
<?php endwhile; | |
wp_reset_query(); | |
?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment