Wordpress:如果两个或多个帖子具有相同的日期,则不显示日期

时间:2009-10-21 11:46:00

标签: php wordpress date

此页面http://www.zoecormier.com/freelance/

显示了一个奇怪的错误

向下滚动到名为“测试turnitin”的文章,您将看到文章日期未显示。它上面的文章(名为“被盗词”)显示日期。这两篇文章的日期相同,但只有一篇正在显示它。

文章列表的代码是:

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

<?php $externalLink = get_post_meta($post->ID, 'external link', true); ?>
<?php $pdfLink = get_post_meta($post->ID, 'pdf link', true); ?>

<ul class="article_index">
    <li class="title"><a href="<?php the_permalink() ?>" title="Read <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <li class="date"><?php the_date('d.m.y') ?></li>
    <li class="publication"><?php echo get_post_meta($post->ID, 'publication', true) ?></li>
    <li class="tags"><?php the_tags(' ',' ',' '); ?></li>
    <li class="link"><?php if ( !$externalLink ) { } else { ?><a href="<?php echo $externalLink ?>"><img src="<?php echo $baseUrl; ?>images/icon_world.gif" alt="Weblink" title="Weblink" width="16" height="16" border="0" /></a><?php } ?></li>
    <li class="pdf"><?php if ( !$pdfLink ) { } else { ?><a href="<?php echo $pdfLink ?>"><img src="<?php echo $baseUrl; ?>images/icon_pdf.gif" alt="View pdf" title="View pdf" height="16" border="0" /></a><?php } ?></li>
</ul>

<?php endwhile; ?>
<?php endif; ?>

一位善良的人可以提供任何想法吗? 感谢。

2 个答案:

答案 0 :(得分:2)

这是the_date()

的文档“功能”

http://codex.wordpress.org/Template_Tags/the_date

特别注意:当在同一天发布的页面上有多个帖子时,the_date()仅显示第一个帖子的日期(即the_date()的第一个实例)。要重复在同一天发布的帖子的日期,您应该使用模板标记the_time()和特定于日期的格式字符串。

答案 1 :(得分:2)

您现在可能已找到答案,但现在是: (适用于3.0版本)

<?php echo get_the_date('', $post->ID);?>