WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Getting products from a category not working properly (1 post)

  1. jitheshkt
    Member
    Posted 8 months ago #

    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);
    var_dump($product_array);

    Returns :

    array(0) {
    }

    What is wrong ?
    What i am missing ?

    http://wordpress.org/plugins/woocommerce/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.