Make WordPress Core

Opened 11 years ago

Closed 6 years ago

#13493 closed feature request (wontfix)

Make the_date() and is_new_day work properly

Reported by: banago Owned by: Otto
Milestone: Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch close
Focuses: template Cc:

Description (last modified by dd32)

Make the_date() always echo the date, in preference the the historic behavior of only echo'ing once per "day"

Otto's recommendations.

a) fix is_new_day() to actually work.
b) change the_date and such to always display the date.

With that patch, somebody could do this for the "only on new days" logic:

if (is_new_day()) the_date();

Anybody who actually needed that new day functionality (rare) could then fix their theme up quite simply with only a minor adjustment.

Attachments (1)

deprecate-is-new-day.13493.diff (1.3 KB) - added by filosofo 11 years ago.

Download all attachments as: .zip

Change History (13)

#1 @banago
11 years ago

  • Keywords needs-patch added; the_date is_new_day removed

#2 @dd32
11 years ago

  • Component changed from Date/Time to Template
  • Keywords reporter-feedback added

What is actually wrong with the_date() / is_new_day() ? Can you provide some back story?

Its been discussed before about the_date() not always echo'ing, The answer has been that themes rely on the current result, as such, changing it to always output is not ideal, as it'll break a lot of themes. the_time() can always be used to display the date on each post, you simply need to pass the "time format" (which can include date markers) as the first parameter.

#3 @banago
11 years ago

Hi dd32,

The back story is that the_date will not acho if you have two or more posts posted in the same date. The function will echo the date in the first post of that date and will leave blank the other ones, which is pretty annoying and not an expected behavior of the_date().

Here is where is_new_date() comes along and if you want to leave blank the date of the other posts of the dame date, than just add this: if (is_new_day()) the_date();

The more important part is that if this function gets fixed, no theme will break for sure - the function will only fill the blank dates of the posts of the same date.

We talked this with Otto in the wp-hackers mailing list and he suggested to make a ticked for this.

#4 @dd32
11 years ago

  • Description modified (diff)
  • Type changed from defect (bug) to feature request

#5 follow-up: @filosofo
11 years ago

  • Keywords has-patch added; needs-patch removed

If you want to print the date every iteration, just use echo get_the_date();

Getting the_date(); to change its behavior to do so is unnecessary, and it's unlikely to win support since it would upset the default behavior of many themes.

Also, it makes more sense to deprecate is_new_day().

  • It's never been used in core WordPress
  • One must use another function (the_date()) within the same block or it won't work.
  • Loop conditions must be the most basic or else it won't work correctly.
  • It's bad programming form and poorly named.
  • A more reliable and generally useful approach to accomplishing similar goals would be to use modulus on a Unix time integer. If we need syntactic sugar for that, then let's handle that in a new function.

#6 in reply to: ↑ 5 ; follow-up: @banago
11 years ago

Replying to filosofo:

Getting the_date(); to change its behavior to do so is unnecessary, and it's unlikely to win support since it would upset the default behavior of many themes.

I agree with deprecating is_new_day(). However, being a theme developer I would disagree with your assumption about the_date() not getting support for changing default behavior. The is because, I get mad every time the_date() hides me dates and than I end up using the_time() to show it every time. Also, many developers, me included, when not developing with text that has posts in the same date, will use the_date() and will end up producing buggy code as the client is expecting the function to show the date of every post of the same day.

So, even though the historical behavior is such, it is a buggy feature - if I can put it like that - and needs to be fixed.

#7 in reply to: ↑ 6 @filosofo
11 years ago

Replying to banago:

So, even though the historical behavior is such, it is a buggy feature - if I can put it like that - and needs to be fixed.

I agree that it's sorta ridiculous behavior, but it's intentional, documented, widely-used, and historical behavior. Therefore by definition it's not buggy--the bug has become a feature.

What I'm saying is that in general, when something is widely-used in themes, its default behavior won't be changed. Instead, the way people usually work around that situation is by adding additional arguments to the function or deprecating it for another.

In this case, jeremyclarke has already worked around it by introducing get_the_date(): r12917 Use it instead.

#8 @nacin
11 years ago

  • Milestone changed from Awaiting Triage to Future Release

#9 @hakre
10 years ago

X-Ref: #8532

#10 @nacin
8 years ago

  • Component changed from Template to Date/Time
  • Focuses template added

#11 @obenland
7 years ago

  • Keywords close added; reporter-feedback removed

Original discussion on the mailing list: http://lists.automattic.com/pipermail/wp-hackers/2010-May/032046.html

I'm not sure how we could change the behavior of the_date() in any backwards compatible way, without adding another parameter.

r12917 is probably the closest we can get to using a date function with the expected behavior, that is not called the_date().

Suggesting wontfix.

#12 @wonderboymusic
6 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

agree with obenland

Note: See TracTickets for help on using tickets.