It’s important to keep your blog or website up-to-date for it to rank well in Search Engines. This will also improve your reader engagement since the content remains relevant the more it’s updated.
For people using WordPress as their content management system (CMS), a more effective way to show recent posts is by moving the updated or edited content to the top of your blog posts page. This may drive better traffic to your posts and compete with other wesbites.
This short article has been written to help you display recently edited posts first in WordPress blog or website. We will cover two easy methods.
Method 1: Adjusting post publication date
The easiest method is manually adjusting the publication date of your articles. Let’s look at an example.
Go to your WordPress Dashboard –> Posts –> All Posts, and click the post for editing.
On next edit screen, locate the Publish
meta box on the right side.
Click on the shown date under “Publish“. Change the date and time to “Now“. You can also set any custom date you want shown on the post.
You will see the date now says “Immediately“.
Click “Update” to reset post publication date. If you open the post link, it show show the current date.
Method 2: Using a Plugin
if you want a more automated process, you can install a plugin that will adjust post’s date automatically whenever you edit it. Check out the following plugin:
Install and start enjoying automated posts date updating on your posts when you edit them.
Method 3: Use Custom Code
The custom code method involves editing the functions.php
theme file. To persist this across theme updates, use Child theme.
Find your theme functions.php
file and add the following code at the end.
function update_post_date_on_save($post_id) {
// Check if this is not an auto-save or a revision
if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) {
return;
}
// Get the current post
$post = get_post($post_id);
// Update the post date to the current date and time
$current_date = current_time('mysql');
wp_update_post(array(
'ID' => $post_id,
'post_date' => $current_date,
'post_date_gmt' => get_gmt_from_date($current_date)
));
}
add_action('save_post', 'update_post_date_on_save');
Save the changes to the file and test by editing a post.
Conclusion
It’s easy to keep your content fresh and up-to-date by manually adjusting the dates, using a plugin, or by adding custom PHP code to your functions.php file. If you need any assistance from CloudSpinx team, connect with us using Live Chat button in the far bottom left corner.