忍者ブログ
22 September

TCDテーマ 子テーマCSSを読み込む

http://community-net.jp/media-web/wordpress-theme-child-create
https://ja.wordpress.org/support/topic/%E8%A4%87%E6%95%B0%E3%81%AEcss%E3%82%92%E8%AA%8D%E8%AD%98%E3%81%95%E3%81%9B%E3%81%9F%E3%81%84/page/2/

TCDテーマ用

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'));

wp_register_style( 'pc-style',get_template_directory_uri(). '/style_pc.css' ,array(),'', 'screen and (min-width: 641px)');
wp_enqueue_style( 'pc-style' );
wp_register_style( 'sp-style',get_template_directory_uri(). '/style_sp.css' ,array(),'', 'screen and (max-width: 640px)');
wp_enqueue_style( 'sp-style' );

wp_register_style( 'child-pc-style',get_stylesheet_directory_uri(). '/style_pc.css' ,array(),'', 'screen and (min-width: 641px)');
wp_enqueue_style( 'child-pc-style' );
wp_register_style( 'child-sp-style',get_stylesheet_directory_uri(). '/style_sp.css' ,array(),'', 'screen and (max-width: 640px)');
wp_enqueue_style( 'child-sp-style' );

}


上記をfunctions.phpに書き込み、header.php内のcss読み込み先を、親テーマから子テーマURLに書き換える



ちょうどタイムリーにWPフォーラムに質問がきていて助かった!
TCDテーマは子テーマで使用するにあたりつまづくことが多々ある
fontフォルダやimgフォルダは親からコピってこないと反映されないし、get_template_part 
使わずにinclude使ってたりしてphpが読み込めてないことがある
single.phpやarchive.php内で読み込んでる navigation.php で遭遇した

新しいテーマばっかだして古いテーマはほったらかし
子テーマ使用が当たり前のようになってきてるのになんなの?有料なんだからちゃんとやれよ
メールの返信も遅いしサポートはまじ使えないレベル
いじりたいけど自分で直せない人はTCD使わないほうがいい

良い点はマニュアルが満点
PR