Support » Fixing WordPress » lost formatting when Replacing the_date() with the_time()

  • I just got wordpress this afternoon and I love it. I applied the Human Condition template but wanted to have the date on every post instead of once per day. Tried changing the template tag to the_time() in the index file and it works, i now have the date on every post, but it’s not formatted as it was before.

    what I did was replace
    <?php the_date(”,'<h2>’,'</h2>’); ?>
    with
    <?php the_time(‘jS F Y’,'<h2>’,'</h2>’); ?>

    it seems like the_time() is not picking up the h2 style. is there a way to fix this? Thanks in advance!
    Tyson

Viewing 5 replies - 1 through 5 (of 5 total)
  • the_time() doesn’t offer the same arguments as does the_date() (was never sure why), so you’ll need to place its php tag within an <h2> element:

    <h2><?php the_time('jS F Y'); ?></h2>

    http://codex.wordpress.org/Template_Tags/the_time

    Moderator Ryan Boren

    (@ryan)

    WordPress Dev

    the_time() does not support before and after args. Just do this:

    <h2><?php the_time('jS F Y'); ?></h2>

    Moderator Ryan Boren

    (@ryan)

    WordPress Dev

    Hey, two answers that agree. How novel. 😉

    the_date() supports before and after because it only creates output when the day changes. If you surrounded it with header tags, those tags would have nothing in between them for posts that aren’t on a day boundary.

    the_time(), on the other hand, always creates output. You will never end up with empty tags.

    awesome, thanks guys

    Was more like a short story, actually. But it had a satisfying end…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘lost formatting when Replacing the_date() with the_time()’ is closed to new replies.