调整日期格式,更改似乎隐藏代码


Adjusting date format, changing seems to hide code?

我正在尝试调整我的Wordpress主题上的日期格式,例如"1月20日"而不是完整的日期。

我已经根据Wordpress codex调整了代码:

<time datetime="<?php the_date( 'j, S, M' ); ?>" pubdate><?php the_date(); ?> </time>

根据古抄本,应该是1月17日

奇怪的是,这确实显示在代码中,当我查看页面源或检查,但没有显示在视图的任何地方。检查后的代码如下:

<time datetime="17, th, Jan" pubdate=""> </time>

所以它似乎生成了正确的代码,但没有输出它。我做错了什么?

<time datetime="<?php the_date( 'j, S, M' ); ?>" pubdate><?php the_date(); ?> </time>

应该是这样的:

<time datetime="<?php the_date( 'j, S, M' ); ?>" pubdate><?php the_date( 'j, S, M' ); ?> </time>

您没有将参数传递给第二次调用the_date(),这是一个将显示在视图中,另一个是作为一个属性输出,不会显示可见性。

随着在the_date()的seconds调用中传递参数以按照您的要求格式化日期,它将是

the_date('jS, M'); // output 20th, Jan
<time datetime="<?php the_date( 'jS, M' ); ?>" pubdate><?php the_date('jS, M'); ?> </time>