女武神的终末第三季免费观看,国产精品va无码二区,欧美日韩在线视频观看,国产在线观看网站

WordPress 另一種加載父主題樣式的方法

2018-09-05 wordpress經驗
  • 文章介紹
  • 快速入門
  • 評價&建議

有些時候為個性化主題,我們會制作子主題方便修改主題功能外觀,而不用修改原主題,通常我們會用:

  1. @import?url(?‘../parent-theme-folder/style.css’?);

這種方式加載父主題的樣式。

詳見:

但使用@ import方式加載樣式也有一定的缺點,比如:加載慢等。

我們可以使用另一種加載父主題樣式的方法:

  1. add_action(?‘wp_enqueue_scripts’,?‘my_parent_theme_css’?);
  2. function?my_parent_theme_css()?{
  3. ????wp_enqueue_style(?‘child-style’,?get_stylesheet_uri(),?array(?‘parent-style’?)?);
    1. add_action(?‘wp_enqueue_scripts’,?‘my_enqueue_styles’?);
    2. function?my_enqueue_styles()?{
    3. ????/*?If?using?a?child?theme,?auto-load?the?parent?theme?style.?*/
    4. if?(?is_child_theme()?)?{
    5. ????????wp_enqueue_style(?‘parent-style’,?trailingslashit(?get_template_directory_uri()?)?.?‘style.css’?);
    6. /*?Always?load?active?theme’s?style.css.?*/
    7. ????wp_enqueue_style(?‘style’,?get_stylesheet_uri()?);
      1. add_action(?‘wp_enqueue_scripts’,?‘my_dequeue_styles’,?11?);
      2. function?my_dequeue_styles()?{
    8. }
0 0

企業建站推薦正版商業主題,國內專業團隊開發,完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!

立刻開啟你的建站之旅
QQ在線客服

服務熱線

wordpress建站咨詢