アクションフックwp_enqueue_style('');の表記はNGでしょうか。
-
【困っていること】
○アクションフックを利用し、ページによって読み込むcssを制御しています。
○テンプレートがメインで利用しているcssが分からず 、全ページ共通cssの指定を空にしています。
以下の書き方で動作は問題ないのですが、このままでよろしいでしょうか。//* Add new css.
function register_style() {
wp_register_style(‘style’, get_bloginfo(‘template_directory’).’/../prose/style.css’);
wp_register_style(‘home’, get_bloginfo(‘template_directory’).’/../prose/css/home.css’);
wp_register_style(‘single’, get_bloginfo(‘template_directory’).’/../prose/css/single.css’);
wp_register_style(‘category’, get_bloginfo(‘template_directory’).’/../prose/css/category.css’);
}
function add_stylesheet() {
register_style();
// 全ページ共通
wp_enqueue_style(”);
// TOPページ専用
if (is_home()){
wp_enqueue_style(‘home’);
}
// 投稿・カスタム投稿ページ専用
elseif (is_single()) {
wp_enqueue_style(‘single’);
}
// カテゴリページ専用
elseif (is_category()) {
wp_enqueue_style(‘category’);
}
}
add_action(‘wp_print_styles’, ‘add_stylesheet’);新規で作成したcssはhome.css、single.css、category.cssです。
ご教示頂ければ幸いです。よろしくお願い申し上げます。【環境】
アプリケーション名 WordPress 4.3.1
テンプレート genesis 子テーマProse (http://www.studiopress.com/)
- トピック「アクションフックwp_enqueue_style('');の表記はNGでしょうか。」には新たに返信することはできません。