nurise
@nurise
Front-end, WordPress, Design

Почему the_date() в WordPress выводится через раз в цикле?

Дата выводится у первого и третьего поста в цикле, но не у второго и четвертого. В чем может быть проблема the_date()?

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

    <?php $custom_fields = get_post_custom(); ?>

    <article class='event-preview'>
      <div class='event-preview__image'>
        <a href='<?php the_permalink(); ?>'><?php the_post_thumbnail( 'medium' ); ?></a>
      </div>
      <header class='event-preview__header'>
        <h3 class="event-preview__title">
          <a href='<?php the_permalink(); ?>'><?php the_title(); ?></a>
        </h3>
        <time class="event-preview__datetime"><?php the_date(); ?> <?php echo $custom_fields['Event Time'][0]; ?></time>
      </header>
      <?php
        $original_title = get_the_title();
        $title = "Read more about ${original_title}";
        the_content_limit(100, $title);
      ?>
    </article>
  <?php endwhile; endif; wp_reset_postdata(); ?>
  • Вопрос задан
  • 952 просмотра
Решения вопроса 1
dimasmagadan
@dimasmagadan
это стандартное поведение этой функции

When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.

https://codex.wordpress.org/Function_Reference/the_date

используйте the_time() или get_the_date()
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы