I am trying to build a custom shop page. For this page I am building a custom shortcode and I am trying to use the default (if that exists) Woocommerce query for showing products. I guess I need this because I would like woocommerce filter widgets, such as filter by price and filter by attribute, to work.

I tried creating my own query like

$args = array(
    'post_type' => 'product');
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
    while ( $loop->have_posts() ) : $loop->the_post();
        wc_get_template_part( 'content', 'product' );
} else {
    echo __( 'No products found' );

But filtering products, through the WC filter widgets, has no effect on a query like this. I also tried using a shortcode to retrieve the products like


This allowed me to filter by price, but not by attribute.

I was wondering if there is any way to use the default WC loop (like in archive-product.php / shop page) in order to retrieve products on my custom shop page AND keep the filter widgets active.

Any help is greatly appreciated!


I wrote a post that does exactly what you need. See here: https://cfxdesign.com/create-a-custom-woocommerce-product-loop-the-right-way/

  • You should copy the answer here too @cfx – Eoin Jul 4 '20 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.