当サイト、Codex 日本語版は今後積極的な更新は行わない予定です。後継となる新ユーザーマニュアルは、https://ja.wordpress.org/support/ にあります。
万が一、当サイトで重大な問題を発見した際などは、フォーラムWordSlack #docs チャンネルでお知らせください。</p>

関数リファレンス/add theme support

提供: WordPress Codex 日本語版
< 関数リファレンス
2010年9月3日 (金) 18:43時点におけるMizuno (トーク | 投稿記録)による版 (原文コピー)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

このページ「関数リファレンス/add theme support」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

Description

Allows a theme to register support of a certain feature. This should be called in the theme's functions.php file.

Usage

%%%<?php add_theme_support( $feature ); ?>%%%

Parameters

$feature
string) (必須) Name for the feature the feature being added.
初期値: なし

Features list:

  • 'custom-header'
  • 'custom-background'
  • 'post-thumbnails'
  • 'menus'
  • 'automatic-feed-links'
  • 'editor-style'

Addable Features

Custom Header

%%%<?php add_theme_support('custom-header'); ?>%%% This option enables custom-header support for a Theme. With this option enabled, the Appearance Header SubPanel is made available, enabling the user to upload and/or specify a custom header image or color. This option became available with Version 3.0.

This option is used internally, and should not be called directly by a Theme. Instead, use add_custom_image_header() in functions.php:

Custom Background

%%%<?php add_theme_support('custom-background'); ?>%%% This option enables custom-background support for a Theme. With this option enabled, the Appearance Background SubPanel is made available, enabling the user to upload and/or specify a custom background image or color. This option became available with Version 3.0.

This option is used internally, and should not be called directly by a Theme. Instead, use add_custom_background() in functions.php:

Default usage: %%%<?php add_custom_background(); ?>%%%

Post Thumbnails

%%%<?php add_theme_support('post-thumbnails'); ?>%%% This option enables post-thumbnail support for a Theme. This option became available with Version 2.9.

This option must be called before the init hook is fired. That means it needs to be placed directly into functions.php or within a function attached to the after_setup_theme hook:

Displaying post thumbnails

// in your theme index.php or single.php or custom templates
the_post_thumbnail();

Checking if thumbnail assigned before displaying

Check if there is a post thumbnail assigned to the post before displaying it.

if (has_post_thumbnail()) {
  the_post_thumbnail();
}

Navigation Menus

%%%<?php add_theme_support('menus'); ?>%%% This option enables Theme support for the naviagation menu ability. This option became available with Version 3.0.

When registering custom menus with register_nav_menus() you do not need to call add_theme_support( 'menus' ). register_nav_menus() automatically registers custom menu support for the theme.

Feed Links

%%%<?php add_theme_support('automatic-feed-links'); ?>%%% This option enables post and comment RSS feed links to head. This should be used in place of the deprecated automatic_feed_links. This option became available with Version 3.0.

Editor Style

%%%<?php add_theme_support('editor-style'); ?>%%% This option enables custom Visual Editor CSS support for a Theme. With this option enabled, the Theme can provide a custom CSS file (editor-style.css) that will allow the Visual Editor display to coincide with the visual output of the Theme itself. This option became available with Version 3.0.

This option is used internally, and should not be called directly by a Theme. Instead, use add_editor_style() in functions.php:

Default usage: %%%<?php add_editor_style(); ?>%%% Custom Visual Editor style sheet filename: %%%<?php add_editor_style('editor-style'); ?>%%% Where 'editor-style' is the name of the CSS file that contains the Visual Editor CSS information. (Note: defaults to 'editor-style.css')

Notes

Change Log

  • 2.9: Introdeced with 'post-thumbnails' feature
  • 3.0: Added 'menus', 'automatic-feed-links', 'custom-header', 'custom-background' and 'editor-style' features

Source File

add_theme_support() is located in wp-includes/theme.php.

Related

テーマサポート: add_theme_support(), remove_theme_support(), current_theme_supports()
テーマ機能: サイドバー, ナビゲーションメニュー, 投稿フォーマット, 投稿サムネイル, カスタム背景, カスタムヘッダー, 自動フィードリンク, html5, コンテンツ幅, editor-style



関数リファレンステンプレートタグ目次もご覧ください。

最新英語版: WordPress Codex » Function Reference/add theme support最新版との差分