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

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??

Read More

Thanks

Related posts

Leave a Reply

9 comments

  1. 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
    */
    
  2. 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.

  3. 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.

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