最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to properly create a child theme

programmeradmin2浏览0评论

I would like to create a child theme based on the twentyeleven theme. I understand how to create my own styles.css file to work for my child theme.

I would also like to create my own custom

header.php
index.php
footer.php
functions.php

files. My question is what information do I need to have placed in the header of each file.

Currently the copied index.php file has:

/**
 * The main template file.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 */

Since this is my index.php file for my child theme what do I need to change?

I would like to create a child theme based on the twentyeleven theme. I understand how to create my own styles.css file to work for my child theme.

I would also like to create my own custom

header.php
index.php
footer.php
functions.php

files. My question is what information do I need to have placed in the header of each file.

Currently the copied index.php file has:

/**
 * The main template file.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 */

Since this is my index.php file for my child theme what do I need to change?

Share Improve this question asked Feb 7, 2012 at 16:50 TikaL13TikaL13 1091 gold badge1 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 5

style.css is the one and only required file in a child theme. It provides the information header by which WordPress recognizes the child theme, and it replaces the style.css of the parent.

As with any WordPress theme, the information header must be at the top of the file, the only difference being that in a child theme the Template: line is required, so that WordPress knows which theme is the parent of the child theme.

Here is an example information header of a child theme’s style.css:

/*
Theme Name:     Twenty Eleven Child
Theme URI:      http: //example/
Description:    Child theme for the Twenty Eleven theme 
Author:         Your name here
Author URI:     http: //example/about/
Template:       twentyeleven
Version:        0.1.0
*/

A quick explanation of each line:

  • Theme Name. (required) Child theme name.
  • Theme URI. (optional) Child theme webpage.
  • Description. (optional) What this theme is. E.g.: My first child theme. Hurrah!
  • Author URI. (optional) Author webpage.
  • Author. (optional) Author name.
  • Template. (required) directory name of parent theme, case-sensitive.
  • NOTE. You have to switch to a different theme and back to the child theme when you modify this line.
  • Version. (optional) Child theme version. E.g.: 0.1, 1.0, etc.

The part after the closing */ of the header works as a regular stylesheet file. It is where you put the styling rules you want WordPress to apply.

more details: http://codex.wordpress/Child_Themes

You don't have to have a specific header for any child php file. It just has to be within your child theme folder. Only your child's style.css requires a specific header.

http://codex.wordpress/Child_Themes

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论