Skip to content

How to Auto-Update WordPress Plugins and Themes (in Code)

Keeping WordPress core up-to-date has become so easy in the last few years that I barely even thing about it. Keeping WordPress plugins and themes up-to-date is currently still a more complex task. There are plugin-based solutions for it, but in this video we cover the method that’d be more favored by those who love writing PHP: the code that makes WordPress auto-update your plugins and themes.

There is some need for obvious provisos here: don’t auto-update plugins and themes that you don’t trust to keep working. Don’t enable auto-updates this way if you don’t have a solid backup system in place. Don’t use this solution of PHP-based auto-updates if your site looking weird when a plugin update doesn’t work will cause you (or someone else) to get fired.

With all those reasons why not, there’s one really good reason to do it: an updated WordPress plugin is more secure well over 95% of the time than an un-updated one. That means that while this isn’t an unquestionable win, it usually is one. Here’s how to do it on video:

How to Enable WordPress Plugin Auto-Updates in PHP Code

  1. Create your plugin or theme functions.php file. The Codex recommends that you use an mu-plugin  to do that — that is a “must-use” plugin that WordPress always has on. But WordPress will honor this code if it’s in an enable plugin or theme as well.
  2. Put in the line of code: add_filter( 'auto_update_plugin', '__return_true' );
  3. Put in the line of code: add_filter( 'auto_update_theme', '__return_true' );
  4. Make sure this code is somewhere it will run. If you’ve created this as a new plugin in the mu-plugins directory, it will. If you’ve enabled the (normal) plugin, it will. If you have it in functions.php of your currently running theme, it will.
Yay! 🎉 You made it to the end of the article!
David Hayes

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Mike
August 8, 2019 7:36 pm

Great video, thanks.
Your two lines update plugins and themes.
How do you recommend we set up WP to auto-update any major or minor WordPress release?

Mick
November 3, 2017 11:29 am

FYI: You link for “are plugin-based solutions for it,” is.. wrong 😉 if you know what I am saying.

Please fix.

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

2
0
Would love your thoughts, please comment.x

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

20 Best Free WordPress Themes for 2024 (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...