WordPress.org

Forums

[resolved] Displaying the default date within a template (6 posts)

  1. gmcgreevy
    Member
    Posted 9 years ago #

    I changed the default format for the date in the admin| options| general menu to "d M y" but I can't see a way of displaying it to my satisfaction.

    What I would like it to view the date as with forum formatting next to every post on every view within the blog, but it says in the codex that <?php the_date(); ?> will only display the date the first time it's called. The time tags won't return the date unless I manually enter the parameters into each template page. I would like to be able to set up the forum formatting centrally without having to change each individual template page. Am I missing something here?

    I'm using a modified blogtimes theme, by the way.

    Thanks in advance.

  2. Jonathan Dingman
    Member
    Posted 9 years ago #

    If I'm understanding you correctly, you want to change the default date. You can do so by Admin Panel > Options > Change the Default Date Format

    Post back if that doesn't fix your issue.

  3. gmcgreevy
    Member
    Posted 9 years ago #

    Sorry, that's not what I meant. What I want is to display the default formattin on every post in every view so that if I change the default from the Admin Panel the formatting will synchronise throughout the blog. Hence why I don't want to format each mention of the date individually with the PHP formatting d M y etc.

    (It's a new blog and a community blog, so I wanted to try a few different formats before settling on one, without having to do loads of template editing).

    So I've experimented with the tag "<?php the_date(); ?>" which does pick up the default as it's supposed to. But the reason I didn't want to use that tag was because of what it says in the codex; that it will only display the date the first time it's called. I suspect I misunderstood that expression, and I thought that the date might not appear on a refresh. I am seeing the date as expected now though, so I don't think there is a problem after all.

    So what does that mean, that "it will only display the date the first time it's called"?

    Thanks for the reply.

  4. vkaryl
    Member
    Posted 9 years ago #

    It means that if you have more than one post on any given date, the date will display only once for that date.

  5. skippy
    Member
    Posted 9 years ago #

    Use the_time() to display the date in the format that you want.

    Combine that with get_settings('date_format'):

    the_time(get_settings('date_format'))

  6. gmcgreevy
    Member
    Posted 9 years ago #

    That sounds perfect - I had not noticed get_settings as a solution. And thanks for explaining about what that expression meant.

    Gez

Topic Closed

This topic has been closed to new replies.

About this Topic