• Hi there,

    I have products that im selling that go on sale up to a certain period, so i want to alter the woocommerce loop. I have created a acf date field for which i then want to query only products that are on that date or ahead.

    The loop iv got below seems to work fine and only outputs products where the date is today or later. But i now need to implement this into the Woocommerce loop. I did try creating my own archive template and using this query, but it then doesnt show the product categories and only goes straight into the product.

    Any suggestions so that it still shows the categories and then products, and so that i can alter the query as below.

    <?php
    $today = date(‘Ymd’);
    $args = array(
    ‘post_type’ => ‘product’,
    ‘order’ => ‘ASC’,
    ‘posts_per_page’ => 4,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘course_start_date’,
    ‘compare’ => ‘>=’,
    ‘value’ => $today,
    )
    ),
    );

    $the_query = new WP_Query( $args );

  • The topic ‘Altering the product/category loop’ is closed to new replies.