WordPress the_date() 函数在文章列表同一天的日期只显示一次的问题

给客户做的网站首页,在文章列表中原本要显示日期和标题的地方,日期只显示第一个,后面的文章标题显示正常,日期都不显示。

 

此处我用来显示日期的是一个很普通的WordPress函数:the_date()
查了一下WordPress的官方文档,有这么一段提示:

SPECIAL NOTE: 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.

意思是当同一天发布多篇文章时the_date()在同一个页面(同一篇文章)中,只输出一次,如果要在同一天发布的帖子都显示日期,你需要用the_time() 或者 get_the_date()这两个函数。于是把原来的

改成以下两条的任意一条,即解决问题。

注:echo不能去掉,否则不会输出内容。

特别说明 ︰ 当同一天发布多篇文章时,the_date() 只显示的日期的第一篇 (就是 the_date()) 的第一个实例。要重复日期根据同一天发布的文章,你应该使用模板标签 the_time() 或 get_the_date();

1 评论
  1. admin
    admin
    2020年4月24日 at 上午6:49

    暫時沒有遇到這個情況,或者以後會遇到呢,學習一下~

    Reply
我想说两句

如果你想在评论中显示自定义头像, 请点击 gravatar! *

专业提供WordPress网站建设、主题定制、插件开发和维护优化等服务

New to site? Create an Account


Login

Lost password? ×

Already have an account? Login


Signup

×

Forgot Password

×
Scroll Up