использовать короткий код [get_specific_product_shortcode id = 'здесь введите идентификатор продукта']
function get_specific_product_shortcode_function($atts){
extract( shortcode_atts(
array(
'id' => '',
), $atts )
);
ob_start();
$args = array(
'posts_per_page' => 1,
'post__in' =>array($id),
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'product',
'post_status' => 'publish',
);
$query = new WP_Query( $args );
$count = $query->found_posts;
if($query->have_posts()){
while( $query->have_posts() ) { $query->the_post();
$post_thumbnail_id = get_post_thumbnail_id();
$product = wc_get_product(get_the_ID());
if (!empty($post_thumbnail_id)) {
$image_size = 'medium'; // (thumbnail, medium, large, full or custom size)
$img_url_arr = wp_get_attachment_image_src( $post_thumbnail_id, $image_size );
$img_url = $img_url_arr[0];
}else{
//placeholder image
$img_url = home_url().'/wp-content/uploads/woocommerce-placeholder.png';
}
?>
<div>
<a href="<?php echo get_permalink();?>">
<img src="<?php echo $img_url?>" style="width: 150px;">
</a>
<div>Price: <?php echo $product->get_price_html(); ?></div>
<div><?php echo get_the_title();?></div>
</div>
<?php
}
wp_reset_postdata();
}else{
echo 'no post'; echo "<br>";
}
return ob_get_clean();
}
add_shortcode('get_specific_product_shortcode', 'get_specific_product_shortcode_function');