2016-10-22 164 views
0

我想创建一个WordPress的儿童主题,并已访问以下网站:https://codex.wordpress.org/Child_Themeswordpress儿童主题functions.php

在这个网站上,它说我必须创建两个文件,其中style.css清晰,我的问题是有关functions.php。它说,在某些时候,我要复制粘贴到新建functions.php文件下面的文字:

<?php 
function my_theme_enqueue_styles() { 

    $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. 

    wp_enqueue_style($parent_style, get_template_directory_uri() . '/style.css'); 
    wp_enqueue_style('child-style', 
     get_stylesheet_directory_uri() . '/style.css', 
     array($parent_style), 
     wp_get_theme()->get('Version') 
    ); 
} 
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); 
?> 

我不知道在这个PHP文件我必须做出修改,即在哪里我把名我的主题在功能上?

感谢,

纳文

回答

0

添加actionfilter钩子可以通过的functions.php完成

请添加wp_enqueue_scripts代码的functions.php

0

首先,你需要了解儿童主题实际上是如何工作的。子主题使用其父主题的文件,并为子主题生成另一个style.css。通常,人们为设计定制开发新的儿童主题。现在,如果您想添加其他功能或更改默认的功能,您需要将其添加到functions.php中。

在此代码中,您将添加父主题的style.css文件以及子主题。

如果你仍然面临问题,有一个插件来创建子主题。

https://wordpress.org/plugins/one-click-child-theme/

安装插件,现在你只需要选择您的新的子主题的父主题和名字,你是好去。