Support » Plugin: WooCommerce » Getting products from a category not working properly

  • I have a category named ‘My product Cat’. Its ID is 20. Now i have 1 product in this category. Usually in WordPress i use get_posts() function to get all the posts inside a category. But, you see here in my case it returns an empty array always. 🙁

    Here is my code :

    $args = array( 'numberposts' => 100,'category' => 20, 'post_type' => 'product');
    $product_array = get_posts($args);

    Returns :

    array(0) {

    What is wrong ?
    What i am missing ?

  • The topic ‘Getting products from a category not working properly’ is closed to new replies.