サポート » 使い方全般 » 標準の写真ギャラリーの表示の仕方

  • 解決済 sai_office

    (@sai_office)


    写真ギャラリーについてほかのトピも確認しましたがわからなかったので
    こちらで質問させていただきます。

    wordpressに標準でついている機能を使って、
    写真ギャラリーを記事上に表示させたいと思っています。

    そこで写真ギャラリーのカテゴリーは他のカテゴリーと違うため、
    page.php内に以下のコードを書き、テンプレートを切り替えようとしました。

    <?php if(is_attachment()): ?>
    	<?php if (wp_attachment_is_image($post->id)) : ?>
    	<?php $att_image = wp_get_attachment_image_src( $post->id, "full-size"); ?>
    <p class="attachment">
    <img src="<?php echo $att_image[0];?>" width="<?php echo $att_image[1];?>" height="<?php echo $att_image[2];?>" class="attachment-full-size" alt="<?php $post->post_excerpt; ?>" />
    </p>
    	<?php else: ?>
      	<?php the_content(); ?>
      	<?php endif; ?>
    <?php elseif(in_category('5') )  : ?>
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post();
    		/* ループ開始 */ ?>
    		<!--article--><article>
    		<h1>ページタイトル</h1>
    		<!--#wrap_column1--><div class="wrap_column1">
    		<!--article001--><article>
    		<h2>カテゴリタイトル</h2>
    		<?php echo do_shortcode('[gallery exclude='.$id.' size="thumbnail" columns="3"]'); ?>
    		</div><!--end #wrap_column1-->
    		</article><!--end .article001-->
    
    		<?php endwhile; // ループの終わり ?>
    	<?php else : ?>
    	<?php endif; ?>
    <?php else: ?>
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post();
    		/* ループ開始 */ ?>
    			<!--article--><article>
    			<h1>ページタイトル</h1>
    			<p>投稿日:<?php the_time('Y年m月d日(D)'); ?></p>
    			<!--#wrap_column1--><div class="wrap_column1">
    			<section>
    			<div><?php the_content(); ?>
    			<div class="tc mt_20"><?php previous_post_link('%link ','&laquo; %title',FALSE ); ?>|<?php next_post_link('%link ', '%title &raquo;', TRUE); ?></div>
    			</div>
    			</section>
    			</div><!--end #wrap_column1-->
    			</article><!--end .article001-->
    		<?php endwhile; // ループの終わり ?>
    	<?php else : ?>
    		<!--article--><article>
    		<h1>記事がありません</h1>
    		<!--#wrap_column1--><div class="wrap_column1">
    		<section>
    		<p>表示する記事はありませんでした。</p>
    		</section>
    		</div><!--end #wrap_column1-->
    		</article><!--end .article001-->
    	<?php endif; ?>
    
    <?php endif; ?>

    しかし、表示される記事には
    [gallery exclude= size="thumbnail" columns="3"]

    とテキストで表示されるだけで、写真が表示されません。

    <?php echo do_shortcode(‘[gallery exclude='.$id.' size="thumbnail" columns="3"]‘); ?>のところを<?php the_content(); ?>に変えてみても[gallery]というテキストが表示されるだけです。

    どういう記述があっているか教えてください。

1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「標準の写真ギャラリーの表示の仕方」には新たに返信することはできません。