@Work Note

 HOME   WP:オリジナルテーマの作成ポイント

WP:オリジナルテーマの作成ポイント

ヘッダ内に必ず「<?php wp_head(); ?>」を入れる
※ </head>の手前
※ 基本 header.php

    <?php wp_head(); ?>
</head>

body開始直後に「<?php wp_body_open(); ?>を入れる
※ 基本 home.php, single.php

<body>
    <?php wp_body_open(); ?>

ファイル構造(基本)

<?php get_header(); ?>

  <main>
	<section>
		<?php while (have_posts()) : the_post(); ?>
		  <h2><?php the_title(); ?></h2>
		  <?php the_content(); ?>
		<?php endwhile; ?>
	</section>
  </main>

<?php get_footer(); ?>

CSSの読み込ませ方(基本)

WPの推奨方法としてはfunction.php内で記述する
※ テーマフォルダ内にxxxx.cssを置く場合

<?php
// テーマフォルダ内の「style.css」を読み込む場合
add_action( 'wp_enqueue_scripts', function(){
  wp_enqueue_style( 'my-style', get_template_directory_uri() . '/style.css' );
} );