how can i get a list of products with the id of their category?!
in the code below $pid is what the user type in shortcode, ‘object_id’ is the id of the every product in wp_posts table.
<?php
$products = $wpdb->get_results("SELECT object_id FROM {$wpdb->term_relationships}
WHERE term_taxonomy_id = " . $pid);
if(!empty($products))
{
foreach($products as $product)
{
//the code
}
}
?>