0
쿼리와 일치하는 게시물이없는 경우 WP_query 매개 변수를 변경하려고합니다. 특히 monthnum 값을 변경하려면 현재 달 표시 할 게시물이없는 경우 새로운 monthnum 값으로 쿼리를 다시 실행하고 싶습니다.루프 내부의 WordPress 쿼리 매개 변수 수정
$query = new WP_Query (array('category_name'=> $cat,'year' => $ano, 'monthnum' => $monthnum, 'posts_per_page' => $posts_per_page, 'post__not_in' => array($id)));
if ($query->have_posts()) : ?>
while ($query->have_posts()) : $query->the_post();
//do something
endwhile;
else:
$monthnum = $monthnum - 1;
if($monthnum == 0){
$monthnum = 12;
}
/*
here I want to run the query again with the new $monthnum value
*/
endif;
wp_reset_query();
해결책을 알고 계십니까? 도와주세요, 제발! 감사.
게시물이 발견되지 않으면이 질문은 대체 검색어가 아닙니다. 게시물이 발견 될 때까지 월별 값을 1 씩 줄이려고합니다. –