Wordpress Filter post by product_cat
<p>I’m having trouble filtering posts (product) by product category. Tried several ways, I’m a newbie.</p>

<p>On my archive-product template I’ve come to execute a report (via SQLREPORTS plugin) with this query:</p>

<pre><code>SELECT `post_title` AS Alumno, `comment_author` AS 'Profesor',  `comment_date`  AS 'Fecha', `comment_content` AS 'Nota' 
FROM `xi00_3_comments` 
INNER JOIN `xi00_3_posts` ON `comment_post_ID`=`ID` 
WHERE `comment_author` != 'WooCommerce'
AND DATE(comment_date) BETWEEN DATE_ADD(DATE_ADD(NOW(),INTERVAL -1 MONTH), INTERVAL 0 DAY) AND DATE(NOW())
AND comment_approved = '1'
ORDER BY `xi00_3_comments`.`comment_date` DESC 
</code></pre>

<p>It runs just fine  and I get all comments from all posts. (my page is filtered by product category by now).</p>

<p>I’ve managed to get the value for the current category: (say value ‘3b’)</p>

<pre><code>   [query_vars] =&gt; Array
    (
        [product_cat] =&gt; 3b

$category =  get_query_var('product_cat','msg if not set');
</code></pre>

<p>Can you help on how should I structure my query to include taxonomy and limit posts to those with a given product category?
I"m aware i need to include taxonomy and terms but can't figure it out.</p>

<p>Thank you so much.</p>