template-**.php をアップロードする
<?php /* Template Name:本体 */ get_header(main); ?>
<?php while(have_posts()): the_post(); ?>
<?php remove_filter('the_content', 'wpautop'); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_footer(main); ?>
この場合は、template-main.phpのほかに、呼び出すfooter-main.phpとheader-main.phpを準備。※ページ専用ヘッダフッタ
固定ページを作る
wp_head()のcssの読み込みもまるきり変えたいとき
wp_head()用のcssの出力が書いてあるところに、分岐を入れる。
if (is_page_template('template-main.php')) {
wp_enqueue_style('special', get_template_directory_uri() . '/css-special/style.css');
} else {
wp_enqueue_style('default', get_template_directory_uri() . '/css/style.css');
}

コメント