acrnym
フォーラムへの返信
3件の返信を表示中 - 1 - 3件目 (全3件中)
-
フォーラム: テーマ
返信が含まれるトピック: 投稿画面で追加した画像を出力したい。フォーラム: テーマ
返信が含まれるトピック: 投稿画面で追加した画像を出力したい。nobitoさん申し訳ありません。下記に記しました。
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id="container"> <section> <?php $images =& get_children( 'post_type=attachment&post_mime_type=image' ); $videos =& get_children( 'post_type=attachment&post_mime_type=video/mp4' ); if ( empty($images) ) { // 添付ファイルが無かった } else { foreach ( $images as $attachment_id => $attachment ) { echo wp_get_attachment_image( $attachment_id, 'full' ); } } // 添付ファイルが無い場合のコードを書かない方法: foreach ( (array) $videos as $attachment_id => $attachment ) { echo wp_get_attachment_link( $attachment_id ); }?> </section> <div class="another"> <?php query_posts('showposts=100&cat=6'); while(have_posts()) : the_post(); ?> <a href="<?php the_permalink(); ?>"> <?php if (has_post_thumbnail()): ?> <?php the_post_thumbnail('thumbnail'); ?> <?php endif ?> </a> <?php endwhile; ?> </div><!--another--> </div><!--container-->このようなコードを書きました。<div class=”another”></div>の部分はその他の記事を表示したものです。
結果は、その投稿にアップした画像ではなく、wordpressのメディアにアップロードされている画像が3枚出力されました。フォーラム: テーマ
返信が含まれるトピック: 投稿画面で追加した画像を出力したい。
3件の返信を表示中 - 1 - 3件目 (全3件中)