반응형
WooCommerce는 가격이 아닌 날짜로만 주문하는 것 같습니다.
커스텀 WP_Query를 통해 가변제품을 입고하고 있습니다.
$args = array(
'post_type' => 'product',
'posts_per_page' => 100,
'product_cat' => 'beast-balls',
'orderby' => 'date',
'order' => 'desc'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="product-node cat-beast-balls">
<?php wc_get_template_part( 'content', 'single-product' ); ?>
</div>
<?php endwhile;
}
wp_reset_postdata();
이거 잘 되는 것 같네요.하지만, 저는 ajax를 사용하여 제품을 리로딩하고 있지만, 이 제품과 같은 다른 루프를 사용하고 있습니다.
$args = array(
'post_type' => 'product',
'posts_per_page' => 100,
'product_cat' => 'beast-balls',
'orderby' => 'price',
'order' => 'asc'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="product-node cat-beast-balls">
<?php wc_get_template_part( 'content', 'single-product' ); ?>
</div>
<?php endwhile;
}
wp_reset_postdata();
하지만 'asc'와 'desc' 사이의 순서가 뒤바뀌는 것을 알 수 있어서 적어도 그것은 효과가 있습니다.저의 문제는 값별로 순서가 달라지지 않는 것 같습니다.날짜나 가격에 따라 제품이 주문되는지 루프가 바뀌도록 하려면 어떻게 해야 합니까?
다들 감사합니다.
시도해 보기:
$args = array(
'post_type' => 'product',
'posts_per_page' => 100,
'product_cat' => 'beast-balls',
'orderby' => 'meta_value_num',
'meta_key' => '_price',
'order' => 'asc'
);
언급URL : https://stackoverflow.com/questions/30978777/woocommerce-seems-to-only-orderby-date-and-not-price
반응형
'programing' 카테고리의 다른 글
JS 파일 내 PHP 상수 (0) | 2023.10.14 |
---|---|
Swift ios는 ios9 및 ios10에서 원격 푸시 알림이 활성화되어 있는지 확인합니다. (0) | 2023.10.14 |
MySQL Server가 사라졌습니다(MariaDB - MEMORY Engine) (0) | 2023.10.14 |
클릭할 때 수신기 제거 (0) | 2023.10.14 |
경고: session_start(): 세션 쿠키를 보낼 수 없음 - 헤더는 이미 에 의해 전송되었습니다(출력 시작 시간: (0) | 2023.10.14 |