简体   繁体   English

WordPress的儿童主题无法正常工作

[英]Wordpress child theme don't work properly

I'm new in Wordpress and I'm trying to create a child theme of the Best Education theme but I get some trouble to do that. 我是Wordpress的新手,正在尝试创建“最佳教育”主题的子主题,但是这样做有些麻烦。 My website with the child theme don't looks the same as with the parent theme. 我的带有子主题的网站看起来与父主题不同。

I created a new folder best-education-child and put two files in: style.css and functions.php. 我创建了一个新文件夹best-education-child,并将两个文件放在:style.css和functions.php中。

Here is style.css : 这是style.css:

/*
Theme Name: Best Education Child
Template: best-education
Text Domain: best-education-child
*/

And function.php : 和function.php:

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
  wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>

When using this code I don't get the right font and the navbar isn't displayed properly. 使用此代码时,我没有得到正确的字体,并且导航栏显示不正确。

I also tried to link every css files of the parent theme in fuctions.php : 我还尝试在fuctions.php中链接父主题的每个css文件:

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
  wp_enqueue_style( 'font-awesome', get_template_directory_uri() . 'assets/libraries/font-awesome/css/font-awesome.min.css' );
  wp_enqueue_style( 'bootstrap', get_template_directory_uri() . 'assets/libraries/bootstrap/css/bootstrap.min.css' );
  wp_enqueue_style( 'admin-widget', get_template_directory_uri() . 'assets/libraries/custom/css/admin-widget.css' );
  wp_enqueue_style( 'slick', get_template_directory_uri() . 'assets/libraries/slick/css/slick.min.css' );
  wp_enqueue_style( 'slick-theme', get_template_directory_uri() . 'assets/libraries/slick/css/slick-theme.css' );
  wp_enqueue_style( 'customize-controls', get_template_directory_uri() . 'assets/libraries/custom/css/customize-controls.css' );
  wp_enqueue_style( 'about', get_template_directory_uri() . 'inc/about/css/about.min.css' );
  wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>

Some issues are resolved, the fonts become the good one, but the navbar isn't still correctly displayed (but the navbar is differently displayed as before), content isn't in the good place and there is no way to scroll down the page. 解决了一些问题,字体变好了,但是导航栏仍无法正确显示(但是导航栏的显示方式与以前不同),内容不在适当位置,并且无法向下滚动页面。 In fact that's worst. 实际上那是最糟糕的。

Can anyone help with this ? 有人能帮忙吗 ?

EDIT : 编辑:

Finaly, I made the choice to change the parent theme for another one which looks similar, in this case the child creation works good. 最后,我决定将父主题更改为另一个看起来相似的主题,在这种情况下,孩子的创作效果很好。

I am reading the wordpress codex and find something that I missed and that can maybe solve the problem, haven't try it but may be the answer to the problem : 我正在阅读wordpress编解码器,找到了我错过的东西,也许可以解决问题,但没有尝试过,但可能是问题的答案:

Note: You may need to re-save your menu (Appearance > Menus, or Appearance > Customize > Menus) and theme options (including background and header images) after activating the child theme. 注意:激活子主题后,您可能需要重新保存菜单(“外观”>“菜单”或“外观”>“自定义”>“菜单”)和主题选项(包括背景和标题图像)。

I was having the same problem but using Divi theme, i wrote to support and they gave me the child theme. 我遇到了同样的问题,但我使用Divi主题写信给支持,他们给了我儿童主题。 You can do the same or try with wordpress plugins that creates child themes. 您可以执行相同操作或尝试使用创建子主题的wordpress插件。 Above you have a link to child theme Divi support gave me , it works perfectly. 您上面有一个指向Divi支持的儿童主题的链接,它运行完美。

https://drive.google.com/file/d/1bCuhWvTrWXu2x3xpABFbqwpklDstW4kh/view?usp=sharing https://drive.google.com/file/d/1bCuhWvTrWXu2x3xpABFbqwpklDstW4kh/view?usp=sharing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM