Skip to Content

How to Change the Publish Date on a WordPress Post

How to Change the Publish Date on a WordPress Post

Are you stuck trying to figure out how to change the publish date on a WordPress post? The function is hidden behind an “edit” button.

Use the edit date function to backdate posts or schedule them for a future date.

WordPress not only lets you publish from anywhere. You can publish as though you never missed a deadline.

Furthermore, WordPress has two hooks to load the metadata. Themes can be edited to change the date the post was last updated automatically.

 

How to change the publish date on a WordPress post

In the WP editor, click edit beside “publish immediately” and you can select any date to publish. WordPress theme templates can also be edited to include the last updated date. Include two hooks to “get the date”, and the “modified time” to show the first published date and the last updated date.
 

Change the date and time in the WP editor

Within your editor, above the publish button, there is an “edit” button beside where it reads “Publish immediately”.

Click edit and you can select any date, future or past, instead of using the default setting to publish the content immediately.

Setting a future date will change the “publish” button to show a “schedule” option instead. Because publish is for when the post goes live.

To backdate a WordPress post, set a date to whatever you want in the past and it will be published immediately, with an older date.
 

How to change the Publish date to the “last updated” date?

The publish date and the last updated date use two different hooks on WordPress.

This code

<?php echo get_the_date(); ?>

… will always “get the date”, and it will be for the first published date.

Whichever date you set when you publish or schedule a post, is the date that will be shown.

The code is added (usually) to the single.php file template, or a blog-post template. On larger themes with multiple parts, it may be a separate file for Template Parts > Single.php.

Wherever the code <?php echo get_the_date(); ?>is on your theme, right after that, you can add another snippet of code to show the date the post was last updated.

The code to add the modified time to show a last updated date is:

<time datetime="<?php the_modified_time('Y-m-d'); ?>"><?php the_modified_time('F jS, Y'); ?>
 

Should you show the most recent date instead of the first published date?

The function you use to load the metadata can be deceiving. There are blogs that show the published date is recent, then in the comments, those have discussions from years ago. 

The problem there is that readers are deceived into thinking the content is fresh. Reality bites when the information turns out to be outdated.
 

Show both dates

Something that is handy to know about PHP is that it outputs HTML. You can drop in and out of both coding languages within your template files.

For example:

But <?php echo get_the_author(); ?><?php endif; ?> last updated this on <time datetime="<?php the_modified_time('Y-m-d'); ?>"><?php the_modified_time('F jS, Y'); ?>

The “get the author” function pulls in your user name, or the user name of the person to last update the post.
The “modified time” is the code that shows the last updated time. Not the published date.

By using HTML such as <br> for a line break, and/or <hr> for a horizontal rule, you can have the published date show first, then a line separator followed by a message to state that you have been back and updated the post.

Like this:

Depending on your niche, that little bit of extra information to show visitors that you published the post, AND then went back to update it could make a difference. Little things matter.