每次主题更新 之前对主题模板所做的修改就被复盖了, 所有的改动(比如加广告)都得再重新做一遍, 很不方便. 但总不能一直提示有个主题可以更新 你要知道的 我是有强迫症的.
当然 如果你可以多使用 插件, 多使用 右边工具栏 widget 因为这些是不会随着主题更新而消失的. 其它的修改最好放在子主题里.
1. 子主题的命名最好是父主题后面加 -child 便于区分, 比如 twenty-twelve-child.
2. 子主题文件夹需要放在和父主题 同级的目录下(不是子目录)
wordpress-theme-folder
3. WordPress 需要使用的是子主题 同时需要保留父主题 因为子主题并不包含全部主题需要的文件 如果没在子主题找到文件就会在相应的父主题里寻找.
4. 所有对 functions.php 的修改(额外的过滤函数等) 需要放在子主题下的 同文件名.
5. 需要有一个 rtl.css 子主题文件导入父主题的 rtl.css
1 2 3 4 5 6 7 | /* Theme Name: twenty-twelve-child Template: Right to Left text support. */ @import url("../twentytwelve/rtl.css"); |
/* Theme Name: twenty-twelve-child Template: Right to Left text support. */ @import url("../twentytwelve/rtl.css");
6. 额外的 CSS样式表 需要放在 子主题的 style.css 文件里.
1 2 3 4 5 6 7 8 9 10 11 12 | /* Theme Name: twenty-twelve-child Description: twenty-twelve-child Author: 小赖 Template: twentytwelve (optional values you can add: Theme URI, Author URI, Version, License, License URI, Tags, Text Domain) */ ins { background: #ffffff; text-decoration: none; } |
/* Theme Name: twenty-twelve-child Description: twenty-twelve-child Author: 小赖 Template: twentytwelve (optional values you can add: Theme URI, Author URI, Version, License, License URI, Tags, Text Domain) */ ins { background: #ffffff; text-decoration: none; }
7. 如果需要做其它改动就把相样的 文件拷贝一份到 子主题目录下.
child-theme-example
8. 在 WP 控制面版里 寻找插件 并安装 ‘One Click Child Theme’ 这个插件 会把上面的大部分工作都替你做了 非常方便.
英文: https://helloacm.com/wordpress-child-theme-the-only-things-you-need-to-know/
强烈推荐
- 英国代购-畅购英伦
- TopCashBack 返现 (英国购物必备, 积少成多, 我2年来一共得了3000多英镑)
- Quidco 返现 (也是很不错的英国返现网站, 返现率高)
- 注册就送10美元, 免费使用2个月的 DigitalOcean 云主机(性价比超高, 每月只需5美元)
- 注册就送10美元, 免费使用4个月的 Vultr 云主机(性价比超高, 每月只需2.5美元)
- 注册就送10美元, 免费使用2个月的 阿里 云主机(性价比超高, 每月只需4.5美元)
- 注册就送20美元, 免费使用4个月的 Linode 云主机(性价比超高, 每月只需5美元) (折扣码: PodCastInit2022)
- PlusNet 英国光纤(超快, 超划算! 用户名 doctorlai)
- 刷了美国运通信用卡一年得到的积分 换了 485英镑
- 注册就送50英镑 – 英国最便宜最划算的电气提供商
- 能把比特币莱特币变现的银行卡! 不需要手续费就可以把虚拟货币法币兑换
微信公众号: 小赖子的英国生活和资讯 JustYYUK