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

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

「投稿フォーマット」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(3.1: en:Post Formats 11:01, 12 November 2010 Bono 版を翻訳用にコピー)
 
(日本語版用にリンク・見出し・カテゴリを調整/要翻訳)
1行目: 1行目:
 
{{NeedTrans}}
 
{{NeedTrans}}
  
[[Post Formats]], introduced with [[Version 3.1]], are meta information that can be used by themes to customize presentation of a post.  The basic idea is to
+
'''Post Formats''', introduced with [[Version 3.1]], are meta information that can be used by themes to customize presentation of a post.  The basic idea is to
 
provide a specific method for specifying the display "format" of a post.  This replaces the need to use categories to accomplish the same thing, and even more importantly, is portable between themes that support those formats!
 
provide a specific method for specifying the display "format" of a post.  This replaces the need to use categories to accomplish the same thing, and even more importantly, is portable between themes that support those formats!
  
Using '''Asides''' as an example, in the past, a category called Asides was created, and posts were assigned that category, and then displayed differently based on styling rules from [[Template_Tags/post_class|post_class()]] or from [[Conditional Tags|in_category('asides')]].
+
Using '''Asides''' as an example, in the past, a category called Asides was created, and posts were assigned that category, and then displayed differently based on styling rules from [[テンプレートタグ/post_class|post_class()]]/[[:en:Template Tags/post_class|en]] or from [[Conditional Tags|in_category('asides')]].
  
With [[Post Formats]], the new approach allows a theme to define a Post Format (e.g. [[Function_Reference/add_theme_support|add_theme_support('post-formats', array( 'aside'))]]), and then the post format can be selected in the Publish meta box when saving the post.  A function call of [[Function_Reference/get_post_format|get_post_format( $post->ID )]] can be used to determine the format, and [[Template_Tags/post_class|post_class()]] will also create the "format-asides" class, for pure-css styling.
+
With '''Post Formats''', the new approach allows a theme to define a Post Format (e.g. [[関数リファレンス/add_theme_support|add_theme_support('post-formats', array( 'aside'))]]), and then the post format can be selected in the Publish meta box when saving the post.  A function call of [[関数リファレンス/get_post_format|get_post_format( $post->ID )]]/[[:en:Function_Reference/get_post_format|en]] can be used to determine the format, and [[テンプレートタグ/post_class|post_class()]]/[[:en:Template Tags/post_class|en]] will also create the "format-asides" class, for pure-css styling.
  
 
The following Post Formats are supported.
 
The following Post Formats are supported.
24行目: 24行目:
 
* video - A single video. The first <video /> tag or object/embed in the post content will be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL.
 
* video - A single video. The first <video /> tag or object/embed in the post content will be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL.
  
Themes and plugins can set the format with [[Function_Reference/set_post_format|set_post_format()]] and retrieve the format with [[Function_Reference/get_post_format|get_post_format()]].
+
Themes and plugins can set the format with [[関数リファレンス/set_post_format|set_post_format()]]/[[:en:Function_Reference/set_post_format|en]] and retrieve the format with [[関数リファレンス/get_post_format|get_post_format()]]/[[:en:Function_Reference/get_post_format|en]].
  
== Adding Theme Support ==
+
== Adding Theme Support <span id="Adding_Theme_Support"></span>==
  
Themes need to use [[Function_Reference/add_theme_support|add_theme_support()]] to tell WordPress which post formats to support by passing an array of formats like so:
+
Themes need to use [[関数リファレンス/add_theme_support|add_theme_support()]] to tell WordPress which post formats to support by passing an array of formats like so:
  
 
<pre>add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );</pre>
 
<pre>add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );</pre>
  
Then, in the theme, make use of  [[Function_Reference/get_post_format|get_post_format()]] to check the format for a post, and change its presentation accordingly. Note that posts with the default format will return a value of FALSE.  Or make use of the [[Conditional Tags|conditional tag]] ''has_post_format()'':
+
Then, in the theme, make use of  [[関数リファレンス/get_post_format|get_post_format()]]/[[:en:Function_Reference/get_post_format|en]] to check the format for a post, and change its presentation accordingly. Note that posts with the default format will return a value of FALSE.  Or make use of the [[Conditional Tags|conditional tag]] ''has_post_format()'':
  
 
  if ( has_post_format( 'video' ) {
 
  if ( has_post_format( 'video' ) {
38行目: 38行目:
 
  }
 
  }
  
== Backwards Compatibility ==
+
== Backwards Compatibility <span id="Backwards_Compatibility"></span>==
  
 
If your plugin or theme needs to be compatible with earlier versions of WordPress, you need to add terms named post-format-$format to the "post_format" taxonomy.  For example,
 
If your plugin or theme needs to be compatible with earlier versions of WordPress, you need to add terms named post-format-$format to the "post_format" taxonomy.  For example,
46行目: 46行目:
 
</pre>
 
</pre>
  
You must also register the post_format taxonomy with [[Function_Reference/register_taxonomy|register_taxonomy()]].
+
You must also register the post_format taxonomy with [[関数リファレンス/register_taxonomy|register_taxonomy()]].
  
 
{{原文|Post Formats|94886}}<!-- 11:01, 12 November 2010 Bono 版 -->   
 
{{原文|Post Formats|94886}}<!-- 11:01, 12 November 2010 Bono 版 -->   
  
[[Category:Advanced Topics]]
+
{{DEFAULTSORT:とうこうけいしき}}<!-- 訳語仮置き -->
 +
[[Category:上級トピック]]
 +
[[Category:wp3.1]]
  
 
[[en:Post Formats]]
 
[[en:Post Formats]]

2010年11月12日 (金) 20:21時点における版

このページ「投稿フォーマット」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

Post Formats, introduced with Version 3.1, are meta information that can be used by themes to customize presentation of a post. The basic idea is to provide a specific method for specifying the display "format" of a post. This replaces the need to use categories to accomplish the same thing, and even more importantly, is portable between themes that support those formats!

Using Asides as an example, in the past, a category called Asides was created, and posts were assigned that category, and then displayed differently based on styling rules from post_class()/en or from in_category('asides').

With Post Formats, the new approach allows a theme to define a Post Format (e.g. add_theme_support('post-formats', array( 'aside'))), and then the post format can be selected in the Publish meta box when saving the post. A function call of get_post_format( $post->ID )/en can be used to determine the format, and post_class()/en will also create the "format-asides" class, for pure-css styling.

The following Post Formats are supported.

  • aside - Typically styled without a title. Similar to a Facebook note update.
  • chat - A chat transcript, like so:
John: foo
Mary: bar
John: foo 2
  • gallery - A gallery of images.
  • link - A link to another site. The first <a href=””> tag in the post content will be considered the external link for that post. Alternatively, if the post consists only of a URL, that will be the URL and the title (post_title) will be the name.
  • image - A single image. The first <img /> tag in the post will be considered the image. Alternatively, if the post consists only of a URL, that will be the image URL and the title of the post (post_title) will be the title attribute for the image.
  • quote - A quotation. Suggested UI is a quote text area and a citation textarea. The quote should be saved to post_content as <blockquote>$quote_wrapped_with_paragraphs<p><cite>$citation</cite></p></blockquote>.
  • status - A short status update, usually limited to 140 characters. Similar to a Twitter status update.
  • video - A single video. The first <video /> tag or object/embed in the post content will be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL.

Themes and plugins can set the format with set_post_format()/en and retrieve the format with get_post_format()/en.

Adding Theme Support

Themes need to use add_theme_support() to tell WordPress which post formats to support by passing an array of formats like so:

add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

Then, in the theme, make use of get_post_format()/en to check the format for a post, and change its presentation accordingly. Note that posts with the default format will return a value of FALSE. Or make use of the conditional tag has_post_format():

if ( has_post_format( 'video' ) {
  echo 'this is the video format';
}

Backwards Compatibility

If your plugin or theme needs to be compatible with earlier versions of WordPress, you need to add terms named post-format-$format to the "post_format" taxonomy. For example,

wp_insert_term('post-format-aside', 'post_format');

You must also register the post_format taxonomy with register_taxonomy().

最新英語版: WordPress Codex » Post Formats最新版との差分