If you want to use the Wp_Query
for selecting the single product from the database you have to pass the p
in the $args
so that if fetches the data and the post_type
should be as product
.
Follow up the Normal
$args
method along with that you have to add the following lines of code.
<?php
$params = array(
'p' => 'YOUR PRODUCT ID', id of a page, post, or custom type
'post_type' => 'product'
);
$wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'No Product' ); ?></p>
<?php endif; ?>