“get_the_post_image”で取得した画像にリンクやテキストを追加表示させたい
-
以下の手順で、エントリーの特定部位にギャラリーを表示しているのですが、以下の仕様を追加したいと考えています。
その実現に際して皆様のお知恵をお貸しいただければと思い投稿させていただきました。追加希望
・表示される縮小画像(現状だと’thumbnail’指定)の画像をクリックすることで拡大画像が開けるよう自動的にリンクさせたい。
・画像の下に説明文を表示したい。 ALTタグの内容でいいので写真の下にテキストを自動で表示させることはできないでしょうか?index.php側ソース
<ul class="contents_entry"> <?php get_the_post_image(get_the_ID(), 'thumbnail', 0, 6); ?> </ul>
functions.php側追加ソース
/**メディア内の写真を掲載 */ function get_the_post_image($postid,$size='full',$offset=0,$numberimages=-1) { $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => null, 'numberposts' => $numberimages, 'offset' => $offset, 'post_parent' => $postid, ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo '<li>'; echo wp_get_attachment_image( $attachment->ID, $size ); echo '</li>'; } } }
宜しくお願い致します。
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「“get_the_post_image”で取得した画像にリンクやテキストを追加表示させたい」には新たに返信することはできません。