【问题标题】:the_date(); is not displaying after additional posts日期();附加帖子后不显示
【发布时间】:2017-12-03 22:44:28
【问题描述】:

目前在加载最近的帖子后在 Wordpress 中显示日期有点问题。

在最近的帖子中,帖子会显示日期。以前的帖子不显示日期。

我正在使用 the_time() 来获取帖子的创建时间,这对于我所有连续的帖子都很好。

这是我的 HTML:

<div class="sectionContainer col-xs-10">

<div class="sectionHeader">
    <p>Recent posts <img src="<?php bloginfo('template_directory'); ?>/gator-alt.svg" class="img-responsive pull-right"></p>
</div>

<div class="postContainer">

    <?php query_posts('showposts=5');

        if( have_posts() ): while( have_posts() ): the_post(); ?>

        <p class="postTitle">
            <?php the_title(); ?>
        </p>

        <p class="postDateTime">
            <?php the_date();?> @
                <?php the_time();?>
        </p>

        <div class="postContentContainer">
            <p class="postContents">
                <?php the_content(); ?>
            </p>
        </div>

        <?php endwhile;
              endif;

        ?>
</div>

这是一张完整描述正在发生的事情的图片。您可以看到最近的帖子显示日期,以前的帖子不显示。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    请注意 the_date() 函数中的以下内容。

    仅当当前帖子的日期与前一个输出的日期不同时才会输出日期。

    尝试使用函数get_the_date()

    【讨论】:

    • 当然。谢谢你的帮助。这是我的第一个 Wordpress 主题,所以我很肯定我已经问了一个非常基本的问题哈哈。
    猜你喜欢
    • 1970-01-01
    • 2014-11-27
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-12
    • 2018-02-04
    相关资源
    最近更新 更多