Correct week filtering logic

This commit is contained in:
savvasha
2018-07-30 22:36:40 +03:00
committed by GitHub
parent ce4389bee9
commit abfa60d60b

View File

@@ -38,8 +38,42 @@ if ( $date == 'day' ) {
}
if ( $date == 'week' ) {
$args['year'] = date( 'Y' );
$args['week'] = date( 'W' );
unset ( $args['monthnum'] );
$args['date_query'] = array(
array(
'month' => date('n'),
'day' => date('j'),
),
array(
'month' => date( "n", strtotime( "+1 day" ) ),
'day' => date( "j", strtotime( "+1 day" ) ),
),
array(
'month' => date( "n", strtotime( "+2 days" ) ),
'day' => date( "j", strtotime( "+2 days" ) ),
),
array(
'month' => date( "n", strtotime( "+3 days" ) ),
'day' => date( "j", strtotime( "+3 days" ) ),
),
array(
'month' => date( "n", strtotime( "+4 days" ) ),
'day' => date( "j", strtotime( "+4 days" ) ),
),
array(
'month' => date( "n", strtotime( "+5 days" ) ),
'day' => date( "j", strtotime( "+5 days" ) ),
),
array(
'month' => date( "n", strtotime( "+6 days" ) ),
'day' => date( "j", strtotime( "+6 days" ) ),
),
array(
'month' => date( "n", strtotime( "+1 week" ) ),
'day' => date( "j", strtotime( "+1 week" ) ),
),
'relation' => 'OR',
);
}
$posts = get_posts( $args );