• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「functions.php 概説」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Functions File Explained 14:06, 8 December 2014 Jdgrimes 版を流し込み。)
(相違点なし)

2015年6月27日 (土) 20:52時点における版

このページ「functions.php 概説」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

One way to change the default behaviors of WordPress is using a file named functions.php. It goes in your Theme's folder.

The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site. You can use it to call functions, both PHP and built-in WordPress, and to define your own functions. You can produce the same results by adding code to a WordPress Plugin or through the WordPress Theme functions file.

There are differences between the two.

A WordPress Plugin:

  • Requires specific, unique Header text.
  • Is stored in wp-content/plugins, usually in a subdirectory.
  • Executes only when individually activated, via the Plugins panel.
  • Applies to all themes.
  • Should have a single purpose, e.g., convert posts to Pages, offer search engine optimization features, or help with backups.

A functions file:

  • Requires no unique Header text.
  • Is stored with each Theme in the Theme's subdirectory in wp-content/themes.
  • Executes only when in the currently activated theme's directory.
  • Applies only to that theme. If the Theme is changed, the functionality is lost.
  • Can have numerous blocks of code used for many different purposes.

Each theme has its own functions file, but only the functions.php in the active Theme affects how your site publicly displays. If your theme already has a functions file, you can add code to it. If not, you can create a plain-text file named functions.php to add to your theme's directory.

A Child Theme can have its own functions.php. This child functions file can be used to augment or replace the parent theme's functions.

With a functions file you can:

Beware: if a WordPress Plugin calls the same function, or filter, as you do in your functions file, the results can be unexpected -- even site-disabling.

Search the web for "WordPress functions.php" to find suggestions to enhance the functionality of your WordPress site.

Resources

最新英語版: WordPress Codex » Functions File Explained最新版との差分