How query price and description of woocommerce product
I am able to output the title of a product with a wordpress query, but I am not sure how to get the price and description, also is it possible to filter by category as well.
Here is my code so far, so where the <?php the_title(); ?> I would like to also out put the price and description from woocommerce prodcuts, and at 'post_type' => 'product' I would like to filter by product category.
Thanks in advance
<?php
$params = array(
'posts_per_page' => 5, //No of product to be fetched
'post_type' => 'product'
);
$wc_query = new WP_Query($params);
if ($wc_query->have_posts()) :
while ($wc_query->have_posts()) :
$wc_query->the_post();
?>
<?php the_title(); ?>
<?php
endwhile;
wp_reset_postdata();
else: ?>
<p><?php _e( 'No Products' );?></p>
<?php endif; ?>
Here is my code so far, so where the <?php the_title(); ?> I would like to also out put the price and description from woocommerce prodcuts, and at 'post_type' => 'product' I would like to filter by product category.
Thanks in advance
<?php
$params = array(
'posts_per_page' => 5, //No of product to be fetched
'post_type' => 'product'
);
$wc_query = new WP_Query($params);
if ($wc_query->have_posts()) :
while ($wc_query->have_posts()) :
$wc_query->the_post();
?>
<?php the_title(); ?>
<?php
endwhile;
wp_reset_postdata();
else: ?>
<p><?php _e( 'No Products' );?></p>
<?php endif; ?>
Комментарии
Отправить комментарий