WordPress.org

Ready to get started?Download WordPress

Forums

Create option for the_date to show all the time (4 posts)

  1. Deni
    Member
    Posted 8 years ago #

    As a new WP user, I couldn't figure out why there was this very nice place to define the date format I prefer to use, but when I looked at my posts, there was a completely different format. The format would vary with the theme I was trying out, but none of them were what I had set. I finally figured it was because the themes were using the_time and a hard-coded format within the files. So I removed their hard-coding and changed instances of the_time to the_date and suddenly my date format appeared.

    But wait! After my change I noticed that the date only showed up on one post per day. I don't normally add more than one post in a given day, but some time I might and I'm a strange person, I guess, who wants it to appear on all of the posts. Or maybe not so strange because it occurred to me that this was the reason the theme designers were using the_time instead of the_date.

    I looked it up in the Codex and found that this is a feature and that designers are encouraged to hard-code the date into the_time function to work around this only-one-post-per-day-gets-the-date thing. That really surprised me.

    Isn't there an easier way around this issue? Wouldn't it be a simple matter to include an option to "Show date on every post" on the page where the general options are set? Just a checkbox would do, with a value of 1 or 0, with 1 being "always show dates." Then there would just be a little alteration to the actual the_date function to check whether or not that option had been set.

    Please let me know why this wouldn't work. I can't believe I'm the only person who ever thought of this, although I didn't find a similar suggestion when I did a search of the forum. Maybe there's something I didn't think of that would cause problems in the program if you implemented this.

  2. silencematters
    Member
    Posted 8 years ago #

    Hi there Deni,

    Have you found a solution to this? I am looking as well, and plan on finding a solution in the next couple of days. If I find anything, I will report back.

  3. silencematters
    Member
    Posted 8 years ago #

    I found an option.
    You have to use the_time instead of the_date
    http://codex.wordpress.org/Template_Tags/the_time
    :)

  4. moshu
    Member
    Posted 8 years ago #

    Deni: Maybe there's something I didn't think of

    Yes. Depending on the layout of the theme, some designers AND bloggers prefer the following markup:
    <h1>Blog title</h1>
    <h2>the_date</h2>
    <h3>post_title</h3>
    <h3>post_title</h3>
    <h2>the_date</h2>
    <h3>post_title</h3>
    ...

    Which is semantically absolutely correct! And in this case you do NOT need the date on every post made the same day.
    However, if your theme's layout is different and not the date is the "defining" heading - put the title in h2 and use the_time template tag wherever it pleases you and it will apear on every post.
    Does it make sense?

Topic Closed

This topic has been closed to new replies.

About this Topic