在Wordpress中的子主题中从父主题中排队多个样式

时间:2017-11-10 20:22:41

标签: css wordpress path styles parent

所以这不是关于在Wordpress中的子主题中将父样式中的样式排入队列的顺序。这是关于风格的路径。

假设我父母的主题名称只是父亲,而儿童主题的名称是儿子。 在我的父母主题中,我已经将normalize,font-awesome和其他样式排列。

我的子主题使用以下函数将样式排入队列,这样可行。那种。

      function my_theme_enqueue_styles() {

      wp_enqueue_style( 'father-style',  get_template_directory_uri() .    '/style.css');
      wp_enqueue_style( 'son-style', get_stylesheet_directory_uri() . '/style.css', array('father-style'), wp_get_theme()->get('Version') );
  }
  add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

问题是,Wordpress会自动将normalize,font-awesome等的路径更改为我的子主题文件夹。我不希望这样,只想在我的父母主题中使用其他样式。我该怎么做?

<link rel='stylesheet' id='father-style-css'  href='//localhost:3000/Wordpress/wp-content/themes/casino/style.css?ver=4.8.3' type='text/css' media='all' />
<link rel='stylesheet' id='son-style-css'  href='//localhost:3000/Wordpress/wp-content/themes/son/style.css?ver=1.2.1' type='text/css' media='all' />

<link rel='stylesheet' id='normailze-css' href='//localhost:3000/Wordpress/wp-content/themes/son/assets/css/normalize.css?ver=4.8.3' type='text/css' media='all' />
<link rel='stylesheet' id='font-awesome-css'  href='//localhost:3000/Wordpress/wp-content/themes/son/assets/css/font-awesome.min.css?ver=4.8.3' type='text/css' media='all' />
Should be father, not son -----------------------------------------------------------------------^^^

谢谢。

----解决方案感谢@ Elvin85

我使用get_stylesheet_directory_uri()将父母主题中的样式排入队列,并且必须将其更改为get_template_directory_uri()以使其按预期工作。

0 个答案:

没有答案