Moving Updated Posts to the Top in WordPress

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.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Let’s clarify the differences between merge requests (commonly called pull requests in GitHub), releases, release candidates (RCs), tags, and branches […]

Kind (which in full means “Kubernetes IN Docker”), is a command line tool that enables you to run Kubernetes clusters […]

Are you looking for an easy way to migrate packages from one cPanel server to a new cPanel server? In […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.