主题

添加wordpress子主题

首先,为什么要加子主题?

因为 主题经常会更新,一更新,就会删除你所有的改动。而子主题相当于是你自己做的主题,不受父主题更新的影响。

一开始,子主题,只有三个文件。functions.php, style.css,  screenshoot.png

参考: astra子主题:  https://wpastra.com/docs/install-astra-child-theme/

blocksy子主题: https://creativethemes.com/blocksy/docs/general/child-theme/

----------

style.css内容:

/**
Theme Name: Astra Child
Author: Brainstorm Force
Author URI: http://wpastra.com/about/
Description: Astra is the fastest, fully customizable and beautiful theme!
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: astra-child
Template: astra
*/

Template: astra   ---这行最重要,其他都可以随便写。

-----------

fcuntions.php 

 

function dmmy_custom_childtheme() {  
 
   wp_enqueue_style( 'partentstyle', get_template_directory_uri ().'/style.css'); 
   wp_enqueue_style( 'styledmcur', get_stylesheet_directory ().'/style.css',9999);   //这行可以不要,像blocksy没有自动加载当前的style.css,则要加上这行。
 
     
}
add_action( 'wp_enqueue_scripts', 'dmmy_custom_childtheme',99  ); //99 is order

 

 

----------------

//子主题:

 define( 'WPDMPATH_MBCHILD',  get_stylesheet_directory_uri () );
 define( 'WPDMROOT_MBCHILD',    get_stylesheet_directory () );
//父主题:
 define( 'WPDMPATH_MB',  get_template_directory_uri () );
 define( 'WPDMROOT_MB',    get_template_directory () );