How to Automatically Update WordPress, Themes and Plugins

     

Updates to WordPress are frequent and they can be a pain to manage – especially if you have plenty of WordPress sites to take care of. It takes time to log in to each of them individually and then click update buttons. And what if you’re on a long trip and important security update is released and there’s no access to Internet. In this case, you can’t upgrade WordPress and risk yourself getting hacked.

So what’s the remedy? Hiring somebody to frequently check out for WordPress updates? Nope. You can do it all by yourself: by adding a couple of lines to the WordPress configuration files. The first file is the one called wp-config.php which houses base configuration for your WordPress installation. Second is your theme’s functions.php, hosting settings for your themes. So let me tell you how to enable these automatic updates:

Step 1 – With your favorite FTP/SCP client (I use WinSCP with Notepad++ editor), establish a connection to your hosting server.

Step 2 – Go to the directory where WordPress is installed. Chances are the directory is called public_html.

Step 3 – Find a file called wp-config.php and open it.

Step 4 – Scroll to the bottom of the file. It should look like this:

Unmodified wp-config.php file of WordPress installation

Step 5 – Now, add this line, right after require_once(ABSPATH . ‘wp-settings.php’);

define( 'WP_AUTO_UPDATE_CORE', true );

Your configuration file should now look like this:

Modified wp-config.php file of WordPress installation

Step 6 – After saving the file, it’s time to go to your theme’s functions.php file. It’s located in /wp-content/themes/<yourtheme/ directory.

Step 7 – Scroll to the bottom of the functions file. For the default Twenty Seventeen theme it looks like this:

The functions.php for default Twenty Seventeen WordPress theme

Step 8 – Add these two lines to the end of the functions.php file:

add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );

If it was functions.php of Twenty Seventeen theme, it would now look like this:

Modified functions.php for default Twenty Seventeen WordPress theme

Step 9 – Save the file and enjoy automatic updates for your WordPress!

The above three lines now make your WordPress core files, plugins and themes update automatically. That is, when the WordPress developers team or plugin/theme author releases a new version of his product.

Quick explanation

The first line, define( ‘WP_AUTO_UPDATE_CORE’, true ); defines a constant called WP_AUTO_UPDATE_CORE to be true. It’s pretty self-explanatory: now all WordPress core automatic updates are enabled.

The two add_filter lines in theme’s functions.php add filters to allow automatic updates for plugins and themes. This can, however, be a risky thing to do. Read more on that below.

Any bad things about this?

Yeah. If you’ve made modifications to WordPress, they will be overwritten automatically. Of course they would also get overwritten if you upgraded WordPress the manual way, but at least in that case you’d first be notified of the available updates – rather than them getting installed without you knowing. So if you’ve made a lot of edits to WordPress, automatic updates can make those modifications go away in a blink of an eye. You can choose not to make modifications directly to core files, themes and plugins – instead, make a plugin yourself if you want to tinker with the code.

If you haven’t modified WordPress files, using automatic updates is rather risk-free. In addition, it enhances security because you’ll get fixes for security holes right away when the patch is released. Often, without automatic updates, there can be a long interval between the update release by the author and update install by the blog admin!

Share Your Thoughts

Have something to say about this post? Then say it by filling the form below!

(required):

: