如何编辑Wordpress主题并使其易于更新?
如何开始在 WP 主题内进行更改,然后跟踪它们以供将来更新?
How can you start making changes inside a WP theme and then keep track of them for future them updates ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用某种版本控制软件(例如 Subversion)来跟踪更新。另外,就“黑客”而言,它全部基于 PHP,因此您可以直接进入主题并根据需要对任何文件进行更改,因为它们与您想要执行的操作有关。例如,为了对标头进行任何类型的更改,通常您需要编辑 header.php 文件。
You can use some sort of version control software like subversion to track updates. Also in terms of just "hacking", it is all based in PHP so you can just drop into your theme and make changes as needed to any of the files as they pertain to what you want to do. For example in order to make any sort of changes to the header, typically you would edit the header.php file.
一种方法是使用版本控制系统,例如 Subversion。
One way would be a version control system like Subversion.
我的经验表明,最好选择一个开发良好且可定制的主题(有时需要付费),它允许您在主题设置中进行大部分更改,而不是对其进行硬编码。当作者更新主题时,虽然并非不可能,但我发现他们很少从以前的版本中删除一些东西。如果他们这样做了,他们通常不仅会提供理由,还会提供可能的解决方法。
另一个想法是拥有一个测试环境,您可以在其中尝试主题的新版本,而不会冒对您的实时网站造成损害的风险。只需谷歌“wordpress 测试环境”,这应该会为您指明正确的方向。作为记录,我在备用 Windows 电脑上运行 XAMPP 来执行此过程。
最后一点建议:如果您确实对主题进行了任何更改,请定期备份主题文件。如果出现问题,您无需从头开始设计网站。
My experience has shown that it is best to go with a very well developed and customizable theme (occasionally paid) that allows you to make the majority of changes within the theme's settings rather than hard coding them. When the theme is updated by the author, while not impossible, I find it is rare they've butchered something from a previous version. If they did, they'll often offer not only a reason but a possible work-around.
Another think would be to have a testing environment where you can try out new releases of a theme without risking harm to your live site. Just google 'wordpress testing environment' and that should point you in the right direction. For the record, I run XAMPP on a spare windows pc for this process.
Last bit of advice: if you do make any changes to your theme, back the theme files up regularly. In the event something does go haywire, you wont have to design the site from scratch.