WordPress 博客子主题需要知道的事情


每次主题更新 之前对主题模板所做的修改就被复盖了, 所有的改动(比如加广告)都得再重新做一遍, 很不方便. 但总不能一直提示有个主题可以更新 你要知道的 我是有强迫症的.

当然 如果你可以多使用 插件, 多使用 右边工具栏 widget 因为这些是不会随着主题更新而消失的. 其它的修改最好放在子主题里.

1. 子主题的命名最好是父主题后面加 -child 便于区分, 比如 twenty-twelve-child.
2. 子主题文件夹需要放在和父主题 同级的目录下(不是子目录)

wordpress-theme-folder Wordpress 博客子主题需要知道的事情 wordpress 互联网 网站信息与统计

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 Wordpress 博客子主题需要知道的事情 wordpress 互联网 网站信息与统计

child-theme-example

8. 在 WP 控制面版里 寻找插件 并安装 ‘One Click Child Theme’ 这个插件 会把上面的大部分工作都替你做了 非常方便.

英文: https://helloacm.com/wordpress-child-theme-the-only-things-you-need-to-know/

GD Star Rating
loading...
本文一共 367 个汉字, 你数一下对不对.
WordPress 博客子主题需要知道的事情. (AMP 移动加速版本)
上一篇: 这样的短裙不错
下一篇: 2015-7-1 英国迎来史上最高温

扫描二维码,分享本文到微信朋友圈
d97744134bbd19f1e31fda2b0e84cb88 Wordpress 博客子主题需要知道的事情 wordpress 互联网 网站信息与统计

2 条评论

评论