php displays products of category woocommercer.
opa blz amigo I went through a similar difficulty after much research I found this
sources
List only products in the wp category
My code stays like this
$args =
array (
'post_type' => 'product',
'per_page' => '12',
'columns' => '4',
'orderby' => 'title',
'order' => 'asc',
'product_cat' =>'secadores',
// 'tag_ID' => '116'
);
/* array(
'post_type' => 'product',
'posts_per_page' => 6,
'orderby' => 'rand'
);
*/
$loop = new WP_Query( $args );
/* $loop = new WP_Query( $args ); */
if ( $loop->have_posts() ) {
// while ( $loop->have_posts() ) : $loop->the_post(); global $product;
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li style="width: 33.0%!important;" class="product type-product status-publish has-post-thumbnail product_cat-mesa-de-sinuca-e-jantar product_cat-mesa-de-sinuca-personalizada first instock sold-individually shipping-taxable purchasable product-type-simple">
<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 ); ?>
<?php
if (has_post_thumbnail( $loop->post->ID ))
echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
else echo '<img class="attachment-shop_catalog size-shop_catalog wp-post-image" src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="300px" height="255px" />';
?>
</a>
<div class="collection_desc clearfix">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" class="collection_title">
<h3><?php the_title(); ?></h3>
</a>
</div>
<div class='row'>
<div class=''>
<div class=' custom-title-product'>
<a href=".$link.">
<h3 class='custom-title-product'><?php echo $title ?></h3>
</a>
</div>
<div class='text-center custom-value'>
<span>
<?php echo $currency . $valor ?>
</span>
</div>
<div class='text-center'>
<span class='custom-inf-parcela '> ou em até <?php echo $qt_parcela ?> x de </span>
<span class='custom-valor-parcela'> R$ <?php echo $parcela ?> </span>
<span class='custom-inf-parcela '> na entrega </span>
</div>
<div class='text-center'>
<span class='custom-inf-parcela '> ou apenas </span>
<span class='custom-valor-parcela'> R$ <?php echo $avista ?> </span>
<span class='custom-inf-parcela '> à vista na entrega <span>
</div>
</div>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul><!--/.products-->
<?php
// wc_get_template_part( 'content', 'product' );
// endwhile;
} else {
echo __( 'No products found' );
}
// wp_reset_postdata();
?>
</ul><!--/.products-->