Slider Revolution 6.4 NOW available!

The following code snippet can be used to auto-populate a grid for your WooCommerce product category pages.

The code below can be added to one of your WooCommerce page templates, such as "archive-product.php".

<?php

    $ids = array();
    $cat = get_query_var('product_cat');
    $args = array( 'post_type' => 'product', 'product_cat' => $cat );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product;

        $ids[] = $loop->post->ID;

    endwhile;
    wp_reset_query();

    // replace "my-grid" with the alias name from one of your grids
    echo do_shortcode('[ess_grid alias="my-grid" posts="'.implode(',', $ids).'"]');

?>

Popular Solutions