M
M
Max Zhukov2018-04-28 12:43:11
WordPress
Max Zhukov, 2018-04-28 12:43:11

Why is the_date in the loop running only in the first wordpress iteration?

Why is the_date in the loop running only in the first wordpress iteration?

<?php
              while ( have_posts() ) :
                the_post();
                ?>
                <div class="row article">
                    <div class="col-lg-4"><img class="img-responsive" src="<?php the_post_thumbnail_url(); ?>" alt="News"></div>
                    <div class="col desc">
                        <time><?php the_date( 'j F Y' ); ?></time>
                        <div class="author">Александр Иванов</div>
                        <a class="title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        <?php the_excerpt() ?>
                        <a class="more" href="<?php the_permalink(); ?>">Подробнее...</a>
                    </div>
                </div>
              <?php endwhile;	?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max Medar, 2018-04-28
@MaksZhukov

Let's take a look at the_date function and see:

* Display or Retrieve the date the current post was written (once per date)
*
* Will only output the date if the current post's date is different from the
* previous one output.
*
* ie Only one date listing will show per day worth of posts shown in the loop, even if the
* function is called several times for each post.

A
Alexey Sklyarov, 2018-04-28
@0example

Why - I will not say, but you should always use . Always, alas, why - I can’t find it either, you can google about the reasons. <?php echo get_the_date( 'j F Y' ); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question