- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/get post gallery images」の版間の差分
(和訳完了。) |
細 (最新のマージ) |
||
(同じ利用者による、間の2版が非表示) | |||
42行目: | 42行目: | ||
// ギャラリーの各イメージに対してループを実行 | // ギャラリーの各イメージに対してループを実行 | ||
− | + | foreach( $gallery as $image_url ) { | |
− | + | $image_list .= '<li>' . '<img src="' . $image_url . '">' . '</li>'; | |
} | } | ||
73行目: | 73行目: | ||
== 関連項目 == | == 関連項目 == | ||
</div> | </div> | ||
+ | [[Function_Reference/get_post_gallery|get_post_gallery()]], | ||
[[Function_Reference/get_post_galleries|get_post_galleries()]], [[Function_Reference/get_post_galleries_images|get_post_galleries_images()]] | [[Function_Reference/get_post_galleries|get_post_galleries()]], [[Function_Reference/get_post_galleries_images|get_post_galleries_images()]] | ||
− | {{ | + | {{Post Formats}} |
− | [[Category: | + | {{Tag Footer}} |
+ | |||
+ | {{原文|Function Reference/get post gallery images|149483}}<!-- 01:04, 8 February 2015 Danblaker 版 --> | ||
+ | |||
+ | [[Category:関数]] | ||
+ | [[Category:wp3.6]] | ||
{{Copyedit}} | {{Copyedit}} |
2015年7月4日 (土) 11:54時点における最新版
投稿に追加された1つまたは複数のギャラリーのうち、最初のギャラリーにある画像の URL を配列として読み出す関数です。
パラメータ
- $post
- (投稿 ID またはオブジェクト) (必須) ギャラリーのある投稿。
- 初期値: なし
戻り値
- (array)
- 画像URLの多次元配列
使用法
<?php $gallery = get_post_gallery_images( $post ); ?>
使用例
A simple example of how to append the raw image URLs to the content of any post or page that has at least one gallery.
function pw_show_gallery_image_urls( $content ) { global $post; // is_single()、is_page() 、is_attachment() いづれかのシングルページに対してのみ実行。 if( ! is_singular() ) return $content; // 投稿にギャラリーが載っていることを確認。 if( ! has_shortcode( $post->post_content, 'gallery' ) ) return $content; // 投稿にある最初の投稿を読み出す。 $gallery = get_post_gallery_images( $post ); $image_list = '<ul>'; // ギャラリーの各イメージに対してループを実行 foreach( $gallery as $image_url ) { $image_list .= '<li>' . '<img src="' . $image_url . '">' . '</li>'; } $image_list .= '</ul>'; // 投稿に画像リストを挿入 $content .= $image_list; return $content; } add_filter( 'the_content', 'pw_show_gallery_image_urls' );
改訂履歴
- 3.6.0 にて導入されました。
ソースファイル
get_post_gallery_images() は wp-includes/media.php
にあります。
関連項目
get_post_gallery(), get_post_galleries(), get_post_galleries_images()
投稿フォーマット: set_post_format(), get_post_format(), has_post_format(), the_post_format_audio() /en, get_the_post_format_media() /en, get_content_audio() /en, the_post_format_chat() /en, get_the_post_format_chat() /en, get_content_chat() /en, add_chat_detection_format() /en, the_post_format_gallery() /en, get_content_galleries() /en, get_post_gallery_images(), the_post_format_image() /en, get_the_post_format_image() /en, get_content_images() /en, the_post_format_quote() /en, get_the_post_format_quote() /en, get_content_quote() /en, the_post_format_url() /en, get_the_post_format_url() /en, get_content_url() /en, the_post_format_video() /en, get_content_video() /en, the_remaining_content() /en, get_the_remaining_content() /en, get_post_format_meta() /en, post_format_content_class() /en, get_post_format_content_class() /en, post_formats_compat() /en
最新英語版: WordPress Codex » Function Reference/get post gallery images (最新版との差分)