문제

I'm sure there is a simple reason/answer for this: Why does

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

give me 2010Archive for? I had expected it would give me Archive for 2010

도움이 되었습니까?

해결책

As most template tags that start with the_ this one echoes time and not returns it (which template tags that start with get_the_ do).

First the_time() fires and echoes year, then its return (null) gets concatenated and echoed with string.

So:

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

Or:

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

다른 팁

You can also use ',' instead of '.' for concatenating strings in echo funcion.

echo 'Archive for ' , the_time('Y');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top