Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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');
share|improve this answer
    
Thank you! And a handy rule-of-thumb for the_function and get_the_function too, thanks :) –  Amanda Dec 6 '10 at 14:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.