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

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

「ギャラリーショートコードの使い方」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(2 版)
(2.9: include, exclude オプション追加 /link オプション追加(バージョン不明)、未翻訳)
10行目: 10行目:
  
 
  [gallery option1="value1" option2="value2"]
 
  [gallery option1="value1" option2="value2"]
 +
 +
You can also print a gallery directly in a template like so:
 +
 +
  <?php echo do_shortcode('[gallery option1="value1"]'); ?>
 +
 +
This works too:
 +
 +
  <?php
 +
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
 +
    print apply_filters( 'the_content', $gallery_shortcode );
 +
  ?>
 +
 +
== Options ==
  
 
The following basic options are supported:
 
The following basic options are supported:
21行目: 34行目:
 
  [gallery id="123"]
 
  [gallery id="123"]
  
; size : specify the image size to use for the thumbnail display.  Valid values include "thumbnail", "medium" and "full".  The default is "thumbnail". For example, to display a gallery of medium sized images:
+
; size : specify the image size to use for the thumbnail display.  Valid values include "thumbnail", "medium", "large" and "full".  The default is "thumbnail". The size of the images for "thumbnail", "medium" and "large" can be configured in WordPress admin panel under Settings > Media. For example, to display a gallery of medium sized images:
  
 
  [gallery size="medium"]
 
  [gallery size="medium"]
27行目: 40行目:
 
Some advanced options are available:
 
Some advanced options are available:
  
; orderby : specify the sort order used to display thumbnails.  The default is "menu_order ASC, ID ASC".
+
; orderby : specify the sort order used to display thumbnails.  The default is "menu_order ASC, ID ASC". "RAND" (random) is also supported.
  
 
; itemtag : the name of the XHTML tag used to enclose each item in the gallery.  The default is "dl".
 
; itemtag : the name of the XHTML tag used to enclose each item in the gallery.  The default is "dl".
35行目: 48行目:
 
; captiontag: the name of the XHTML tag used to enclose each caption.  The default is "dd".  For example, to change the gallery markup to use div, span and p tags:
 
; captiontag: the name of the XHTML tag used to enclose each caption.  The default is "dd".  For example, to change the gallery markup to use div, span and p tags:
  
  [gallery itemtag="div" icontag="span" captiontag="p"]
+
; link: you can set it to "file" so each image will link to the image file. The default value links to the attachment's permalink.
 +
 
 +
; include: comma separated attachment IDs, [gallery include="23,39,45"] will show only the images from these attachments.
 +
 
 +
; exclude: comma separated attachment IDs, [gallery exclude="21,32,43"] excludes the images from these attachments. Please note that '''include''' and '''exclude''' cannot be used together.
 +
 
 +
  [gallery itemtag="div" icontag="span" captiontag="p" link="file"]
  
 
== 変更履歴 ==
 
== 変更履歴 ==
 +
<!-- link オプションは途中から? -->
 +
* [[Version 2.9|2.9]] : include, exclude オプション追加
 
* [[Version 2.5|2.5]] : 新規機能
 
* [[Version 2.5|2.5]] : 新規機能
  
{{原文|Using the gallery shortcode|55141}}
+
{{原文|Gallery Shortcode|81322}}<!-- 12:03, 23 December 2009 Azaozz 版 -->
  
 
{{DEFAULTSORT:きやらりいしよおとこおとのつかいかた}}
 
{{DEFAULTSORT:きやらりいしよおとこおとのつかいかた}}
46行目: 67行目:
 
[[Category:WordPress の開発]]
 
[[Category:WordPress の開発]]
 
[[Category:wp2.5]]
 
[[Category:wp2.5]]
 +
[[Category:wp2.9]]
  
 
[[en:Using the gallery shortcode]]
 
[[en:Using the gallery shortcode]]

2010年1月10日 (日) 16:42時点における版

このページ「ギャラリーショートコードの使い方」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

In WordPress 2.5, the Gallery feature allows the option to add an image gallery to a Post or Page on your WordPress blog.

The [gallery] shortcode is used in a Post or Page to display a thumbnail gallery of images attached to that post. It can be used in its simplest form like this:

[gallery]

There are several options that may be specified using this syntax:

[gallery option1="value1" option2="value2"]

You can also print a gallery directly in a template like so:

 <?php echo do_shortcode('[gallery option1="value1"]'); ?>

This works too:

 <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
 ?>

Options

The following basic options are supported:

columns 
specify the number of columns. The gallery will include a break tag at the end of each row, and calculate the column width as appropriate. The default value is 3. If columns is set to 0, no row breaks will be included. For example, to display a 4 column gallery:
[gallery columns="4"]
id 
specify the post ID. The gallery will display images which are attached to that post. The default behaviour if no ID is specified is to display images attached to the current post. For example, to display images attached to post 123:
[gallery id="123"]
size 
specify the image size to use for the thumbnail display. Valid values include "thumbnail", "medium", "large" and "full". The default is "thumbnail". The size of the images for "thumbnail", "medium" and "large" can be configured in WordPress admin panel under Settings > Media. For example, to display a gallery of medium sized images:
[gallery size="medium"]

Some advanced options are available:

orderby 
specify the sort order used to display thumbnails. The default is "menu_order ASC, ID ASC". "RAND" (random) is also supported.
itemtag 
the name of the XHTML tag used to enclose each item in the gallery. The default is "dl".
icontag 
the name of the XHTML tag used to enclose each thumbnail icon in the gallery. The default is "dt".
captiontag
the name of the XHTML tag used to enclose each caption. The default is "dd". For example, to change the gallery markup to use div, span and p tags:
link
you can set it to "file" so each image will link to the image file. The default value links to the attachment's permalink.
include
comma separated attachment IDs, [gallery include="23,39,45"] will show only the images from these attachments.
exclude
comma separated attachment IDs, [gallery exclude="21,32,43"] excludes the images from these attachments. Please note that include and exclude cannot be used together.
[gallery itemtag="div" icontag="span" captiontag="p" link="file"]

変更履歴

  • 2.9 : include, exclude オプション追加
  • 2.5 : 新規機能

最新英語版: WordPress Codex » Gallery Shortcode最新版との差分