いまさら子テーマ化


wordpressで子テーマ化

デフォルトのフォントが気に入らなかったのと、後いろいろと弄りたい所があったので、放置してましたが、バージョンアップで設定がリセットされるのも面倒なので、いまさらながら、子テーマ化してみました。

  1. 子テーマ用のフォルダを作成
    mkdir ./wp-content/themes/twentyfifteen4s 
  2. 子テーマ用の上書きスタイルを作成
    vi ./wp-content/themes/twentyfifteen4s/style.css
    ---
    /*
    Theme Name: twentyfifteen4s
    Template: twentyfifteen
    */
    @import url('../twentyfifteen/style.css');
    @import url(http://fonts.googleapis.com/earlyaccess/notosansjapanese.css);
    
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    font-family: ”メイリオ”,Meiryo,”ヒラギノ角ゴ Pro W3″,”Hiragino Kaku Gothic Pro”,”HiraKakuPro-W3″,”MS Pゴシック”,”MS PGothic”,Arial, Helvetica,sans-serif;}
    
  3.  

  4. functions.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' );
      wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style')
    );
    }
    ?>
    
  5. その他、変更したphpなどがあればコピーしておきます
    cp -p ./wp-content/themes/twentyfifteen/content.php \
          ./wp-content/themes/twentyfifteen4s/
    

いつもお世話になっております、4geruさんのサイトを参考にさせて頂きました!