• Resolved roxer82

    (@roxer82)


    Hello.

    I want to use the meta property=”article:modified_time” and “article:published_time”, but for the “published_time” I need to get the first publication date, that may not be the one I get from get_the_date(“Y-m-d H:m:s”)

    Is ther any function to get the first publication date/time even if the post date was changed?

    • This topic was modified 4 years, 4 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    get_the_date() is supposed to return the original publication date. Subsequent modification dates can be had with get_the_modified_date().
    https://developer.www.ads-software.com/reference/functions/get_the_modified_date/

    Plugins and themes can modify what these functions return so what they are supposed to do may not be what you get on your site. If all else fails, you can get the raw date data from the WP_Post object’s properties, both in local time (according to the WP timezone setting) and UTC.

    Thread Starter roxer82

    (@roxer82)

    Hi bcworkz, thanks for the answer.
    get_the_date() gives me the date I specify in the article. Since I use to change the date to make it to appear in first place, that’s not the first publication date.

    Moderator bcworkz

    (@bcworkz)

    It’s been a while, but I think I misread your topic, apologies. If you change that date, WP does not formally maintain the original value. You might get something close from revisions or auto-backup, but that’s pretty unreliable.

    If you’re in the habit of modifying that date but wish to keep track of its earliest value, you’d need to develop a custom scheme to do so. You could save the current date from the “draft_to_publish” action hook for example. Save it in postmeta.

    Thread Starter roxer82

    (@roxer82)

    Ok, thanks, I’ll try to save it in postmeta.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get the first publication date on articles with the date changed’ is closed to new replies.