我确定有一个简单的原因/答案:为什么

echo 'Archive for '. the_time('Y');

给我吗 2010Archive for?我曾期望它会给我Archive for 2010

有帮助吗?

解决方案

作为大多数模板标签,以 the_ 这个回声呼应时间而不返回它(哪个模板标签以开头 get_the_ 做)。

第一的 the_time() 开火和回声年,然后返回(null)加入并与字符串回声。

所以:

echo 'Archive for ';
the_time('Y');

或者:

echo 'Archive for ' . get_the_time('Y');

其他提示

您也可以使用','而不是'。用于回声弹性中的串联串。

echo 'Archive for ' , the_time('Y');
许可以下: CC-BY-SA归因
scroll top