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

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

「関数リファレンス/get template part」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Function Reference/get_template_part 22:39, 12 April 2010 Bono 版を翻訳用にコピー/Ramiy, T31os, MichaelH 著)
 
(リンク調整等/未翻訳)
1行目: 1行目:
 +
{{NeedTrans}}
 +
{{テンプレートタグガイド|PHP}}
 +
 
== Description ==
 
== Description ==
 
Load a template part into a template (other than header, sidebar, footer). Makes it easy for a theme to reuse sections of code in a easy to overload way for [[Child Themes|child themes]].
 
Load a template part into a template (other than header, sidebar, footer). Makes it easy for a theme to reuse sections of code in a easy to overload way for [[Child Themes|child themes]].
  
[[Include Tags|Includes]] the named template part for a theme or if a name is specified then a specialized part will be included. If the theme contains no <tt>{slug}.php</tt> file then no template will be included.
+
[[インクルードタグ|Includes]] the named template part for a theme or if a name is specified then a specialized part will be included. If the theme contains no <tt>{slug}.php</tt> file then no template will be included.
  
 
For the parameter, if the file is called "{slug}-{name}.php".
 
For the parameter, if the file is called "{slug}-{name}.php".
  
 
== Usage ==
 
== Usage ==
%%% <?php get_template_part( $slug, $name ) ?> %%%
+
 
 +
<?php get_template_part( $slug, $name ) ?>
  
 
== Parameters ==
 
== Parameters ==
16行目: 20行目:
  
 
=== Using loop.php in child themes ===
 
=== Using loop.php in child themes ===
Assuming the theme folder is wp-content/themes, that the parent theme is twentyten,  and the child theme is ''twentytenchild'', this example will do a [http://www.php.net/manual/en/function.require.php PHP require()] for the named files in this order:
+
Assuming the theme folder is wp-content/themes, that the parent theme is twentyten,  and the child theme is ''twentytenchild'', this example will do a [http://www.php.net/manual/ja/function.require.php PHP require()] for the named files in this order:
 
:#''wp-content/themes/twentytenchild/loop-index.php''
 
:#''wp-content/themes/twentytenchild/loop-index.php''
 
:#''wp-content/themes/twentytenchild/loop.php''
 
:#''wp-content/themes/twentytenchild/loop.php''
34行目: 38行目:
  
 
== Notes  ==
 
== Notes  ==
* Uses: [[Function_Reference/locate_template|locate_template()]]
+
* Uses: [[Function_Reference/locate_template|locate_template()]]/[[:en:Function_Reference/locate_template|en]]
* Uses: [[Function_Reference/do_action|do_action()]] Calls 'get_template_part{$slug}' action.
+
* Uses: [[Function_Reference/do_action|do_action()]]/[[:en:Function_Reference/do_action|en]] Calls 'get_template_part{$slug}' action.
  
 
== Change Log ==
 
== Change Log ==
41行目: 45行目:
  
 
== Source File ==
 
== Source File ==
<tt>get_template_part()</tt> is located in {{Trac|wp-includes/general-template.php}}.
+
<tt>get_template_part()</tt> is located in {{Source|wp-includes/general-template.php|3.0}}.
  
 
{{原文|Function Reference/get_template_part|85902}}<!-- 22:39, 12 April 2010 Bono 版 -->
 
{{原文|Function Reference/get_template_part|85902}}<!-- 22:39, 12 April 2010 Bono 版 -->
49行目: 53行目:
 
{{Tag Footer}}
 
{{Tag Footer}}
  
[[Category:Functions]]
+
{{DEFAULTSORT:Get_template_part}}
 +
[[Category:関数]]
 +
[[Category:wp3.0]]
  
 
[[en:Function Reference/get_template_part]]
 
[[en:Function Reference/get_template_part]]

2010年4月13日 (火) 07:47時点における版

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

Description

Load a template part into a template (other than header, sidebar, footer). Makes it easy for a theme to reuse sections of code in a easy to overload way for child themes.

Includes the named template part for a theme or if a name is specified then a specialized part will be included. If the theme contains no {slug}.php file then no template will be included.

For the parameter, if the file is called "{slug}-{name}.php".

Usage

<?php get_template_part( $slug, $name ) ?>

Parameters

$slug
string) (必須) The slug name for the generic template.
初期値: なし
$name
string) (optional) The name of the specialized template.
初期値: なし

Examples

Using loop.php in child themes

Assuming the theme folder is wp-content/themes, that the parent theme is twentyten, and the child theme is twentytenchild, this example will do a PHP require() for the named files in this order:

  1. wp-content/themes/twentytenchild/loop-index.php
  2. wp-content/themes/twentytenchild/loop.php
  3. wp-content/themes/twentyten/loop-index.php
  4. wp-content/themes/twentyten/loop.php
<?php get_template_part( 'loop', 'index' ); ?>

Navigation

Adding a navigation bar to theme using a gereric nav.php template file:

<?php get_template_part( 'nav' );           // Navigation bar (nav.php) ?>
<?php get_template_part( 'nav', '2' );      // Navigation bar #2 (nav-2.php) ?>
<?php get_template_part( 'nav', 'single' ); // Navigation bar to use in single pages (nav-single.php) ?>

source: wp-tricks.co.il - using get_template_part() to create generic navigation bar

Notes

Change Log

Source File

get_template_part() is located in wp-includes/general-template.php.

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

Related

インクルードタグ: get_header(), get_footer(), get_sidebar(), get_template_part(), get_search_form(), comments_template()


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