wp query – Order post by modified date in WordPress

I’m trying to return on the blog page the results in post edit order.

Everything is working, I just have one problem. The first 3 posts in the blog are out of sync and are not being returned based on the date edited. How come?

Currently in fact it returns me the posts with the following dates:

  • Updated April 28, 2021
  • Updated on April 27, 2021
  • Updated on April 27, 2021
  • Posted on May 3, 2021
  • Updated May 3, 2021

Everything else is ok, I checked. But the problem still remains in those first 3 items. I thought there was a problem with the date, but not even updating it in the DB solved the problem.

How can I solve it? This is my code:


$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
   'post_status' => 'publish',
   'posts_per_page' => 10,
   'orderby' => 'modified',
   'order' => 'DESC',
   'paged' => $paged,

$the_query = new WP_Query( $args );
if ($the_query->have_posts()):

    while ($the_query -> have_posts()) : $the_query -> the_post();?>

        <div class="contenitore-post">

            <div class="corpo-post">

                <div class="img-post">
                    <a class="img-thumbnail" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a>

                <div class="corpo-container">
                <!-- Mostra i meta del post -->
                    <p class="data"><?php echo wp_aggiornamento_data() ?></p>
                    <!-- Mostra il titolo del post -->
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <div class="excerpt">
                       <a class="leggi-altro" href="<?php the_permalink(); ?>">Leggi ora ยป</a>
                       <?php the_excerpt(); ?>



        <?php endwhile; ?>

        <div class="numeratore-pagine">
        $GLOBALS('wp_query')->max_num_pages = $the_query->max_num_pages;
        //Impaginazione numerata
        the_posts_pagination (array (
            'mid_size' => 2,
            'prev_text' => __ ('Indietro', 'textdomain'),
            'next_text' => __ ('Avanti', 'dominio del testo'),
            'screen_reader_text' => ' ',
        <?php else: ?>
            <p class="text-muted">No post.</p>
        <?php endif; unset($the_query); wp_reset_query(); ?>