Quote from web-mate on February 1, 2022, 15:30
hello,
i created a template with custom loop, in order to displays the last 60days products.. query work perfect and displays the correct products.
Sidebar also shows the filters by color or size...
but when i choose an option, results not filtering.. keep showing the same results..
i use woof with woocommerce shortcode for sales products and works fine.. i mean that with custom loop/query filters not work..
can u help me?
the page is this : https://metaphores.gr/tirkouaz/new-in/
my query is this :
$start_date = array(
'year' => date("Y", strtotime("first day of previous month")),
'month' => date("n", strtotime("first day of previous month")),
'day' => date("j", strtotime("first day of previous month"))
);
$end_date = array(
'year' => date("Y", strtotime("+6 week")),
'month' => date("n", strtotime("+6 week")),
'day' => date("j", strtotime("+6 week"))
);
$args = array(
'post_type' => 'product',
'date_query' => array(
array(
'after' => $start_date,
'before' => $end_date,
'inclusive' => true,
),
),
'posts_per_page' => -1,
);
$query = new WP_Query( $args ); ?>
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
/**
* Hook: woocommerce_shop_loop.
*/
do_action( 'woocommerce_shop_loop' );
wc_get_template_part( 'content', 'product' );
}
}
else {
echo 'no prods';
}
do_action( 'woocommerce_sidebar' );
wp_reset_query();
can you please help ..!
thank you...
hello,
i created a template with custom loop, in order to displays the last 60days products.. query work perfect and displays the correct products.
Sidebar also shows the filters by color or size...
but when i choose an option, results not filtering.. keep showing the same results..
i use woof with woocommerce shortcode for sales products and works fine.. i mean that with custom loop/query filters not work..
can u help me?
the page is this : https://metaphores.gr/tirkouaz/new-in/
my query is this :
$start_date = array(
'year' => date("Y", strtotime("first day of previous month")),
'month' => date("n", strtotime("first day of previous month")),
'day' => date("j", strtotime("first day of previous month"))
);
$end_date = array(
'year' => date("Y", strtotime("+6 week")),
'month' => date("n", strtotime("+6 week")),
'day' => date("j", strtotime("+6 week"))
);
$args = array(
'post_type' => 'product',
'date_query' => array(
array(
'after' => $start_date,
'before' => $end_date,
'inclusive' => true,
),
),
'posts_per_page' => -1,
);
$query = new WP_Query( $args ); ?>
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
/**
* Hook: woocommerce_shop_loop.
*/
do_action( 'woocommerce_shop_loop' );
wc_get_template_part( 'content', 'product' );
}
}
else {
echo 'no prods';
}
do_action( 'woocommerce_sidebar' );
wp_reset_query();
can you please help ..!
thank you...