How to disable theme updates on WordPress to avoid losing my changes?
Asked Answered
F

9

49

I was trying to modify a template to should use a Child-theme (using WordPress) so, when parent template updates I wont lose my changes. Well, the problem is that I created a template using parts of other templates. I was thinking about set my style and all like that, but maybe I missed some update command and if any parent template will get an update I might lose all my work.

How can I be completely sure to not add any information about updates on my customized template??

Thanks

Faradic answered 9/6, 2014 at 15:1 Comment(2)
Do you mean that you've created a separate theme, and copied bits of other templates into it? Or have you taken an existing theme and altered it "in place", i.e. editing the existing files?Benzoic
I took one theme, alterated the styles and all, and also added part of another 2 templates, incluiding funcionts and parts of the stylesFaradic
K
61

Open the style.css file and change the theme name and information that is in the comment at the top. This will essentially turn your theme into a child theme and no updates will affect it.

/*
Theme Name: Your Theme Name
Author: Name
Author URI: Your URL
Description: This theme is...
Version: 1.0
*/
Kalynkam answered 9/6, 2014 at 15:44 Comment(4)
I did that, so, I am already safe that no changes will destroy it?Faradic
Yes you are safe. You won't have any problems with theme updates at all.Kalynkam
it is possible that you'll still get update notifications if you use a WooThemes theme, and use the updater plugin, or a similar set up.Lifton
Keep in mind that you might lose theme settings if you change the name of a theme after making settings changes. One of my blog themes stores data in the database suing the theme name as part of the setting name.Creon
M
89

Increase the version number in the style.css to something really high, and you should stop getting the update notices.

Molal answered 5/3, 2015 at 10:53 Comment(1)
This was the best solution for me in a particular case. I'm already using a child theme, but the parent theme's updates destroy the site, so I needed to prevent my admin users from one-clicking an update.Kwabena
K
61

Open the style.css file and change the theme name and information that is in the comment at the top. This will essentially turn your theme into a child theme and no updates will affect it.

/*
Theme Name: Your Theme Name
Author: Name
Author URI: Your URL
Description: This theme is...
Version: 1.0
*/
Kalynkam answered 9/6, 2014 at 15:44 Comment(4)
I did that, so, I am already safe that no changes will destroy it?Faradic
Yes you are safe. You won't have any problems with theme updates at all.Kalynkam
it is possible that you'll still get update notifications if you use a WooThemes theme, and use the updater plugin, or a similar set up.Lifton
Keep in mind that you might lose theme settings if you change the name of a theme after making settings changes. One of my blog themes stores data in the database suing the theme name as part of the setting name.Creon
P
8

if you want to do something clean follow these steps:

  1. Search and replace all "originalThemeName" in your wordpress project with something personalized, like "newThemeName";
  2. Edit the style.css of the theme and set a proper version number (like 1.0 if you just deployed in production)
  3. Rename the folder of the theme with your "newThemeName", then reactivate it from the admin panel.

done, it will no longer compare the original theme with the wordpress themes directory, so it will not find any updates.

Pharmacy answered 30/9, 2015 at 22:21 Comment(2)
Renaming the theme folder isn't always possible though(i know, bad development), so increasing the version number in the css file is typically a more reliable and certainly easier solution. Although, your answer is more robust in an idea scenario.Palate
@PhillHealey - I do see what your getting at. I was more meaning it would be better to download a copy of the theme, make your changes and rename the theme, then ZIP it up and upload it again. Rather than the find/replace aspect of the answer :PFiftyfifty
L
7

in style.css on top portion just change the version to Version: 9.9.9 and it will do the job straight away.

Leiker answered 30/6, 2015 at 6:48 Comment(0)
S
4

Remove this line from wp-config.php :

add_filter( 'auto_update_theme', '__return_true' );

Have a look at this article for more details.

Scaffolding answered 29/12, 2014 at 15:33 Comment(3)
This line is not included on most standard WordPress installations as this would enable AUTO theme updates. So yes, removing this would disable auto updates but would not disable manual theme updates.Kalynkam
This wouldn't work since it's not in wp-config by default. A better solution would be to set the value to false, or add the above filter with the value set to false.Palate
try this "add_filter( 'auto_update_theme', '__return_false' );"Fanatical
D
4

Instead of simply modifying the style.css file of the theme as other answers suggest, I would recommend taking full advantage of child themes. This way, it is possible to update the main theme (e.g. if security vulnerabilities are found or you just prefer to have the latest version) and also retain all of your modifications.

For example, if you want to modify the Twenty Fifteen theme, create a new directory /wp-content/themes/twentyfifteen-child/* and in this directory you need a style.css file with the following:

/*
 Theme Name:   Twenty Fifteen Child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentyfifteen
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fifteen-child
*/ 

Modify accordingly. You can put whatever you want for anything, except the Template line, which must be the same as the directory name of the parent theme. When using child themes, it will load any of the files in your new theme directory in addition to the ones in the parent theme. Specifically, styles.css in the child theme is loaded after the one in the parent theme and functions.php in the child theme is loaded before the functions.php in the parent theme. Any and all modifications to the theme would then be done to the files in the newly created twentyfifteen-child directory.


* This directory can be called anything that you want, but this naming style is recommended since will make it obvious which theme is the parent.

Decarbonate answered 3/6, 2016 at 22:33 Comment(0)
B
1

This code execute once wp loaded

add_action( 'wp_loaded', 'disable_wp_theme_update_loaded' );
function disable_wp_theme_update_loaded() {
    remove_action( 'load-update-core.php', 'wp_update_themes' );
    add_filter( 'pre_site_transient_update_themes', '__return_null' );
}
Bestir answered 3/6, 2020 at 13:47 Comment(1)
this is what I was looking for. A colleague of mine told me that I did not use child themes and that there is a message that tells me to update the theme. I told him I will use blank themes or child themes in the future. I am a big fan o blank themes. I find it too much to work with themes anyway. Your answer helped me to give something to my colleagues and to avoid showing the update message to the client.Eckel
S
0

Using a child theme is the first step - updating the main theme won´t affect your changes.

Nevertheless it is not sufficient to use a child theme to prevent (accidental) updates, because there is a severe bug in the wordpress update-routine: Wordpress first checks whether there is a theme with the same name and a higher version number in the Wordpress repository. If so, it will be offered and imported as an update. It does not matter whether the theme in question is a child theme!

There are two ways that you can work around the problem:

  1. Increase the version number to something really high, just like Alex pointed out. But this is a mere workaround and does not conform to coding standards.
  2. Choose a really unique name for your childtheme, for example always put some abbrevation for your (company) name in front of the theme name. Check if your child themes name is really unique by searching wordpress.org/themes
Sievers answered 4/1, 2022 at 10:43 Comment(0)
U
-1

Add following line in wp-config.php file

define( 'AUTOMATIC_THEME_UPDATES', false );
Udine answered 16/2, 2023 at 8:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.