40行目: 40行目:
* サイトのヘッダ部分を生成
* サイトのヘッダ部分を生成
* <head>内には以下のように記述できる
* <head>内には以下のように記述できる
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php wp_title(); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>

2019年2月21日 (木) 15:04時点における版

テーマの主な構成部品

WrodPressサイト
テンプレートファイルのセット + データベースのデータ

テンプレートファイル

テーマは「テンプレートファイル」と呼ばれる以下のようなファイル群で構成され、wp-content/themes/your_themeディレクトリ内に格納される。

style.css

  • サイトのスタイルシート
  • 冒頭にコメントとしてテーマ詳細を書くと管理画面のテーマ一覧に表示されるようになる
  • ただし、ファイルの一番先頭は @charset
@charset "UTF-8";
/*
Theme Name: hoge
Theme URI: https://hoge.com/themes/hoge
Author: hoge
Author URI: https://hoge
Description: hoge hoge.
Version: 1.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: hoge, hoge
Text Domain: twentythirteen

Use it to make something cool, have fun, and share what you've learned with others.
*/

screenshot.png

テーマ一覧に画像で表示されるようになる。JPEG, GIF でも可。推奨サイズは 880×660

function.php

  • テーマに関するあらゆる機能の実装を指定
  • サイト生成時に読み込まれる
  • 基本的にはメニュー機能、ウィジット機能を実装すべき
  • 基本的にプラグインと同じ動作。記述方法はプラグイン制作がそのまま参考になる

header.php

  • サイトのヘッダ部分を生成
  • <head>内には以下のように記述できる
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php wp_title(); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>