42
votes

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

7
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
I took one theme, alterated the styles and all, and also added part of another 2 templates, incluiding funcionts and parts of the stylesjpganz18

7 Answers

79
votes

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

58
votes

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
*/
6
votes

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.

5
votes

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

5
votes

Remove this line from wp-config.php :

add_filter( 'auto_update_theme', '__return_true' );

Have a look at this article for more details.

4
votes

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.

0
votes

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' );
}