WordPress.org

Ready to get started?Download WordPress

Forums

Two posts - same day - date disappears (6 posts)

  1. EdwardAndrews
    Member
    Posted 8 years ago #

    I use the following code in my main template to show the date and time of the post.

    Written by <?php the_author(); ?> on <?php the_date(); ?> at <?php the_time(); ?>

    If I have two posts on the same day, the date on the second one disappears on the second one. I know I can get it to appear by putting ('F jS, Y') after the_date, but I would like the format of the date to be controlled by the General Options date setting.

    You can see the problem here.

    Any suggestions?

  2. moshu
    Member
    Posted 8 years ago #

    There is a whole section in the Codex describing every template tag. Template_Tags/the_date

  3. MichaelH
    Member
    Posted 8 years ago #

    Use the_time instead of the_date

    See:
    Template_Tags/the_time
    Template_Tags/the_date

    Oops see moshu got to this.

  4. EdwardAndrews
    Member
    Posted 8 years ago #

    I have looked at both those Codex entries already.

    To quote Template_Tags/the_date

    Displays the date using defaults.

    <p>Date posted: <?php the_date(); ?>

    I want to display the date using defaults, so I use the code i put in my first posting. BUT, on the second occasion on one page, the date does not appear. On the second occasion, what appears is

    Written by Edward Andrews on at 1:46 pm

    NO DATE!!

    Any ideas?

  5. Kafkaesqui

    Posted 8 years ago #

    If you read the Description for the_date(), you would find it says:

    When there are multiple posts published on the same date on a page, the tag will only display the date the first time it's called.

    And:

    Note: To display the date for posts individually, use the_time() instead with a date-specific format string.

    If you need to force the default format for your date, here's a little trick for it:

    <?php the_time(get_settings('date_format')); ?>

  6. EdwardAndrews
    Member
    Posted 8 years ago #

    Thank you.

    Edward

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags