single-xxx.phpで最新の投稿しか表示されない
-
カスタム投稿xxxを作って、アーカイブページ(archive-xxx.php)を作成、個別ページ(single-xxx.php)も作成したのですが、なぜか最新の記事しか表示されず困っております。
アドレスバーのURLはきちんと「http://sample.jp/wordpress/?xxx=投稿名」という風になるのにページに表示される内容は最新のものです。。
どこをどう変えればいいのかアドバイス頂けないでしょうか。
お願いします。。single-xxx.phpの内容は以下です。
<?php $args = array( 'numberposts' => 1, 'post_type' => 'xxx' ); $customPosts = get_posts($args); if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post ); ?> <?php $img = get_field('xxx_fv'); $imgurl = wp_get_attachment_image_src($img, 'full'); if($imgurl){ ?><img src="<? echo $imgurl[0]; ?>" alt="" style="width:100%;" /> <? } ?> <div class="content_all xxx_single"> <div class="container"> <h2><?php $txt = get_field('xxx_build'); if($txt){ ?><? echo $txt; ?></h2> <? } ?> <?php $txt = get_field('xxx_content'); if($txt){ ?><strong>内容</strong> <p><? echo $txt; ?></p> <? } ?> <?php $txt = get_field('xxx_place'); if($txt){ ?><strong>場所</strong> <p><? echo $txt; ?></p> <? } ?> <?php $area = get_field('xxx_info'); if($area){ ?> <p><? echo $area; ?></p> <? } ?> <ul class="xxx_single"> <li> <?php $img = get_field('xxx_image1'); $imgurl = wp_get_attachment_image_src($img, 'full'); if($imgurl){ ?><img src="<? echo $imgurl[0]; ?>" alt="" /> <? } ?> </li> <li> <?php $img = get_field('xxx_image2'); $imgurl = wp_get_attachment_image_src($img, 'full'); if($imgurl){ ?><img src="<? echo $imgurl[0]; ?>" alt="" /> <? } ?> </li> <?php endforeach; ?> <?php else : ?> <?php endif; wp_reset_postdata(); ?> <?php wp_pagenavi(); ?> </div> </div> <?php get_footer(); ?>
5件の返信を表示中 - 1 - 5件目 (全5件中)
5件の返信を表示中 - 1 - 5件目 (全5件中)
- トピック「single-xxx.phpで最新の投稿しか表示されない」には新たに返信することはできません。