How to Automatically Update WordPress Plugins and Themes

In our previous articles, we already told you the importance of keeping your WordPress theme and plugins updated. However, in our busy lives, we may not find enough time to log in to WordPress dashboard every day and update WordPress. So to help you with getting your site updated without losing time and focus, there is a feature in WordPress called automatic background update. In this article, we will show you how to automatically update WordPress plugins and themes.

Why you should enable auto update feature

You should always keep your WordPress site updated since newer versions have better security and fewer errors. Same goes for themes and plugins. Newer versions come with advanced features and stronger security. So it is the duty of every website owners to update your WordPress site and plugins regularly. For minor releases, WordPress can update automatically by itself. But for major releases, you have to manually initiate the update. All the plugins and themes have to be manually updated. Popular plugins and themes release updates frequently. So it will be really useful if you set the automatic update for trusted and popular theme and plugins.

How to Automatically Update WordPress Plugins and Themes

Setting up Automatic Update for All WordPress Plugins

Setting automatic update is much simpler than we generally think. You can install a plugin or simply add a few lines of codes to functions.php file or site-specific file.

Using Simple Automatic Updates plugin

If you don’t like to mess with codes in function file, then you can choose the safe option to install an automatic update plugin like Simple Automatic Updates and Automatic Plugin Updates. If you are not familiar with plugins, you can read our article on “What is Plugin in WordPress and How does it work?

Installing and using Simple Automatic Updates plugin is extremely easy. You can install the plugin like any other plugin by going to Plugins > Add New. Then search for terms like Simple Automatic Updates and install the plugin with the following thumbnail as shown in the image below.

Simple automatic update -- Automatically Update WordPress Plugins and Themes

Once installed, you can configure the plugin under Settings > General. Actually, there is no any configuration for this plugin. The only configuration you can set is the option for receiving emails at the end of the general setting page. The plugin will start updating your theme and plugins automatically.

Settings -- Automatically Update WordPress Plugins

If you want to selectively update plugins, then we recommend you use Automatic Plugin Updates. The major advantage of using this plugin is to be able to selectively install updates. There will always be certain plugins which you may not want to update. Maybe you like the current version or any other older versions of any particular theme or plugins. In such cases like Automatic Plugin Updates will be useful.

Using Codes to Automatically Update WordPress Files, Plugins and Themes

You can insert a simple line of code in your function file or site specific plugin. To automatically update WordPress plugins, add the following line to your functions file. This will update all the plugins installed on the website.

add_filter( 'auto_update_plugin', '__return_true' );

Similarly to update all themes automatically, here is the simple code.

add_filter( 'auto_update_theme', '__return_true' );

If you want to have more control and allow automatic updates for certain plugins only then here is the code


function auto_update_specific_plugins ( $update, $item ) {
    // Array of plugin slugs to always auto-update
    $plugins = array ( 
        'akismet',
        'buddypress',
    );
    if ( in_array( $item->slug, $plugins ) ) {
        return true; // Always update plugins in this array
    } else {
        return $update; // Else, use the normal API response to decide whether to update or not
    }
}
add_filter( 'auto_update_plugin', 'auto_update_specific_plugins', 10, 2 );

Automatic Update of WordPress Files

From WordPress 3.7 automatic background updates have been introduced for minor releases. You can choose to enable or disable the major and minor updates using the following code. All you have to do is add this little code to the wp-config.php file.

define( 'WP_AUTO_UPDATE_CORE', true );

WP_AUTO_UPDATE_CORE can have one of three values where each value has a different functionality:

  • True – It will enable development, minor, and major updates.
  • False – It will disable development, minor, and major updates.
  • Minor – It will enable minor updates, and disable development and major updates.
Also Read:   Create and Optimize WordPress Robots.txt for SEO

The codes mentioned here are taken from Codex WordPress.

Conclusion

Newer versions of plugins and themes may not bring good results all the time. There will be cases when incompatibilities and troublesome can occur due to the recent update. In such situations, you can roll back to previous versions. We have an article called “How to Roll Back WordPress Plugin to the Previous Version”. We hope you liked our article on “How to Automatically Update WordPress Plugins and Themes“. Keep reading our other articles on this blog.

The following two tabs change content below.
Kantiman Bajracharya

Kantiman Bajracharya

Kantiman Bajracharya is a freelance web developer. He is a computer geek who has a Bachelor’s degree in Computer Engineering. He has earned lots of satisfied customers while working for numerous successful projects. He is also a WordPress theme creator and web article writer. On free time he likes reading philosophy books, traveling and playing chess.

Share This Post