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

Marc
  • 4,661
  • 3
  • 40
  • 62
jpganz18
  • 5,508
  • 17
  • 66
  • 115
  • 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? – Matt Gibson Jun 09 '14 at 15:04
  • I took one theme, alterated the styles and all, and also added part of another 2 templates, incluiding funcionts and parts of the styles – jpganz18 Jun 09 '14 at 15:05

9 Answers9

87

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

Alex Postushnoy
  • 980
  • 6
  • 7
  • 4
    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. – Jeff Cohan Aug 23 '16 at 15:09
60

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
*/
Marc
  • 4,661
  • 3
  • 40
  • 62
  • I did that, so, I am already safe that no changes will destroy it? – jpganz18 Jun 09 '14 at 15:49
  • 1
    Yes you are safe. You won't have any problems with theme updates at all. – Marc Jun 09 '14 at 21:22
  • 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. – Gray Ayer Jun 06 '15 at 00:47
  • 3
    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. – David Rector Jan 30 '18 at 21:06
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.

yesh
  • 89
  • 1
  • 5
  • 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. – Phill Healey Feb 08 '16 at 10:39
  • @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 :P – SM3RKY Feb 08 '16 at 21:23
6

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

Mark Javed
  • 69
  • 1
  • 1
4

Remove this line from wp-config.php :

add_filter( 'auto_update_theme', '__return_true' );

Have a look at this article for more details.

Raptor
  • 53,206
  • 45
  • 230
  • 366
Sive.Host
  • 75
  • 1
  • 1
  • 6
    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. – Marc Jul 29 '15 at 13:58
  • 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. – Phill Healey Feb 08 '16 at 10:37
  • try this "add_filter( 'auto_update_theme', '__return_false' );" – Anthony Kal Jul 01 '17 at 02:58
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.

Mike
  • 23,542
  • 14
  • 76
  • 87
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' );
}
  • 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. – Tudor Dec 06 '22 at 10:59
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
-1

Add following line in wp-config.php file

define( 'AUTOMATIC_THEME_UPDATES', false );
Sahir
  • 1
  • 2