如何禁用 WordPress 上的主题更新以避免丢失我的更改?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24123059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable theme updates on WordPress to avoid losing my changes?
提问by jpganz18
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.
我试图修改模板以使用子主题(使用 WordPress),因此,当父模板更新时,我不会丢失我的更改。好吧,问题是我使用其他模板的一部分创建了一个模板。我正在考虑设置我的样式等等,但也许我错过了一些更新命令,如果任何父模板将获得更新,我可能会丢失我所有的工作。
How can I be completely sure to not add any information about updates on my customized template??
我如何才能完全确定不会在我的自定义模板上添加任何有关更新的信息?
Thanks
谢谢
回答by Alex Postushnoy
Increase the version number in the style.css to something really high, and you should stop getting the update notices.
将 style.css 中的版本号增加到非常高的水平,您应该停止收到更新通知。
回答by Marc
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.
打开 style.css 文件并更改顶部注释中的主题名称和信息。这基本上会将您的主题变成子主题,并且没有更新会影响它。
/*
Theme Name: Your Theme Name
Author: Name
Author URI: Your URL
Description: This theme is...
Version: 1.0
*/
回答by yesh
if you want to do something clean follow these steps:
如果你想做一些干净的事情,请按照以下步骤操作:
- Search and replace all "originalThemeName" in your wordpress project with something personalized, like "newThemeName";
- Edit the style.css of the theme and set a proper version number (like 1.0 if you just deployed in production)
- Rename the folder of the theme with your "newThemeName", then reactivate it from the admin panel.
- 在你的 wordpress 项目中搜索并替换所有“originalThemeName”,并使用个性化的东西,比如“newThemeName”;
- 编辑主题的 style.css 并设置适当的版本号(如果您刚刚部署在生产中,则为 1.0)
- 使用您的“newThemeName”重命名主题文件夹,然后从管理面板重新激活它。
done, it will no longer compare the original theme with the wordpress themes directory, so it will not find any updates.
完成后,它将不再将原始主题与 wordpress 主题目录进行比较,因此它不会找到任何更新。
回答by Mark Javed
in style.css on top portion just change the version to Version: 9.9.9 and it will do the job straight away.
在顶部的 style.css 中,只需将版本更改为 Version: 9.9.9 即可立即完成工作。
回答by siveict
回答by Mike
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 alsoretain all of your modifications.
我建议不要像其他答案一样简单地修改主题的 style.css 文件,而是建议充分利用子主题。这样,就可以更新主旋律(例如,如果安全漏洞被发现,或者你更喜欢拥有最新版本),并同时保留所有的修改。
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:
例如,如果您要修改二十十五主题,则创建一个新目录/wp-content/themes/twentyfifteen-child/
*并且在此目录中您需要一个style.css
包含以下内容的文件:
/*
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 mustbe 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 additionto the ones in the parent theme. Specifically, styles.css
in the child theme is loaded afterthe one in the parent theme and functions.php
in the child theme is loaded beforethe 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.
相应地修改。除了必须与父主题的目录名称相同的Template
行之外,您可以为任何内容添加任何您想要的内容。使用子主题时,除了父主题中的文件外,它还会加载新主题目录中的任何文件。具体来说,在子主题中在父主题中加载之后,在子主题中在父主题中的functions.php之前加载。对主题的任何和所有修改都将对新创建的目录中的文件进行。styles.css
functions.php
twentyfifteen-child
*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.
*这个目录可以任意命名,但推荐使用这种命名风格,因为这样可以清楚地表明哪个主题是父主题。