I'm trying to get the posts that was updated from today, yesterday and 2 days ago but 2 days ago is showing the result of yesterday. What seems wrong with my code? Today and Yesterday is working fine. And also the post that query showing from yesterday and 2 days ago are only updated once and it was yesterday. I need help I'm a little bit confuse.
<span>Today's Update (<?php echo date('F j, Y'); ?>)</span>
<?php
$args = array (
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'category__in' => array( 3,7 ),
'date_query' => array(
array(
'column' => 'post_modified_gmt',
'after' => 'today',
'inclusive' => true ),
)
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li><a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
echo '</ul>';
} else {
echo "<ul><li>No Update</li></ul>";
}
/* Restore original Post Data */
wp_reset_postdata();
?>
<span>Yesterday Update (<?php echo date('F j, Y',strtotime("-1 days")); ?>)</span>
<?php
$args2 = array (
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'category__in' => array( 3,7 ),
'date_query' => array(
array(
'column' => 'post_modified_gmt',
'after' => 'yesterday',
'inclusive' => true ),
)
);
$the_query2 = new WP_Query( $args2 );
if ( $the_query2->have_posts() ) {
echo '<ul>';
while ( $the_query2->have_posts() ) {
$the_query2->the_post();
echo '<li><a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
echo '</ul>';
} else {
echo "<ul><li>No Update</li></ul>";
}
/* Restore original Post Data */
wp_reset_postdata();
?>
<span>2 Days ago Update (<?php echo date('F j, Y',strtotime("-2 days")); ?>)</span>
<?php
// 2 Days ago post modified.
$args3 = array (
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'category__in' => array( 3,7 ),
'date_query' => array(
array(
'column' => 'post_modified_gmt',
'after' => '-2days',
'inclusive' => true ),
)
);
$the_query3 = new WP_Query( $args3 );
if ( $the_query3->have_posts() ) {
echo '<ul>';
while ( $the_query3->have_posts() ) {
$the_query3->the_post();
echo '<li><a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
echo '</ul>';
} else {
echo "<ul><li>No Update</li></ul>";
}
/* Restore original Post Data */
wp_reset_postdata();
?>
date_query
(PHP)