Support » Plugin: WooCommerce » How to display a list of the products of the current category?

  • Resolved alezander

    (@alezander)


    Hello

    My structure of products is as follows:

    Notebooks (category)
    –Samsung (subcategory)
    —- Product1
    —- Product2
    —- Product3
    –Asus (subcategory)
    —- Product4
    —- Product5
    Smartphones (category)
    –Samsung (subcategory)
    —- Product6
    —- Product7

    How to determine a product category and subcategory, and then display a list of all the products of the current subcategory with product name, price and permalink?

    Now, I am printing the entire list of products with the following code.
    But I do not understand how to limit its current sub-category.

    $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order );

    $args = array
    (‘post_type’=> ‘product’,
    ‘post_status’ => ‘publish’,
    ‘ignore_sticky_posts’ => 1,
    ‘orderby’ => $ordering_args[‘orderby’],
    ‘order’ => $ordering_args[‘order’],
    ‘meta_query’=> array (
    array
    (
    ‘key’=> ‘_visibility’,
    ‘value’ => array(‘catalog’, ‘visible’),
    ‘compare’ => ‘IN’
    )
    ),
    ‘tax_query’ => array(
    array
    (
    ‘taxonomy’ => ‘product_cat’,
    ‘terms’ => array( esc_attr($category) ),
    ‘field’ => ‘slug’,
    ‘operator’ => ‘IN’
    )
    )
    );

    ob_start();
    $products = new WP_Query( $args );

    if ( $products->have_posts() ) : ?>

    <?php //woocommerce_product_loop_start(); ?>

    <?php //woocommerce_product_loop_end(); ?>

    endif;

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

Viewing 1 replies (of 1 total)
  • function widget at the class-wc-widget-product-categories.php and wp_list_categories( apply_filters( ‘woocommerce_product_categories_widget_args’, $cat_args ) ); – all I need to solve this problem

Viewing 1 replies (of 1 total)
  • The topic ‘How to display a list of the products of the current category?’ is closed to new replies.