duangong937906 2014-04-25 10:43
浏览 38
已采纳

WordPress的。 如何防止WordPress删除我手写的代码

For the sake of testing, I implemented some features in the template I use.

For example I inserted this in the index.php file and other files where I need this item to be:

<div class="test-contact">
    <a href="#">
    Contact us
    </a>
</div>

Then the WP update appeared and also update of the template. I updated it all and my item disappeared from the pages.

Is there any way I can make sure my editions will not disappear, for example, at the costumer's site if he decides to update something? How do you deal with that.

I haven't found anything relevant neither here, nor @ google. Hope someone can heads up.

Regards.

  • 写回答

1条回答 默认 最新

  • dssqq64884 2014-04-25 10:47
    关注

    Presumably the index.php file you edited belonged to a theme that you've installed on the wordpress installation. If this an externally developed theme when the creator releases an update it will replace all the files with the new version as described.

    In this instance it would be wise to create a child theme. These inherit the functionality of the parent theme whilst retaining your customized templates and code.

    An alternative method of achieving what you described above to to make use of the widget areas available in the theme. Many themes include multiple areas for placing dynamic widgets and arbitrary text or html in the form of a text widget. You can place your custom html in a text widget and place the widget in the appropriate "sidebar".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?