【问题标题】:Date not showing on consecutive posts on Wordpress日期未显示在 Wordpress 上的连续帖子上
【发布时间】:2010-10-28 16:19:40
【问题描述】:

我有一个只显示“新闻”类别的帖子的新闻部分。代码如下所示。

问题是,只有第一个新闻帖子在它上面有一个日期。最近的“新闻帖子”之后的所有帖子都没有日期。有人知道为什么会这样吗?

<div id="news">

            <?php $my_query = new WP_Query('category_name=news&posts_per_page=6'); ?>
                <marquee ONMOUSEOVER="this.stop();" ONMOUSEOUT="this.start();" direction="up" scrollamount="2" id="newsMarquee">

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

                    <div class="post">
                        <p class="date"><?php the_date(); ?></p>
                        <?php the_content('Read the rest of this entry &raquo;'); ?>
                        <div class="clear"></div>
                    </div>

                <?php endwhile; endif;?>

                </marquee>

        </div><!-- /#news -->

【问题讨论】:

    标签: php html wordpress date


    【解决方案1】:

    已修复问题。

    不得不更改&lt;?php the_date(); ?&gt;

    到:

    <?php the_time('F jS, Y') ?>
    

    希望对大家有所帮助。

    【讨论】:

    • 真的很好,感谢您回答您自己的问题!继续这样做!
    • @HenriqueFoletto:我尽我所能。
    • 'the_time' 比 'the_date' 好几千倍,效果更好,并且可以在一个循环内多次使用!感谢分享!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    相关资源
    最近更新 更多