トップページにブログの新着記事を全文表示させたい
-
wordpress3.8、テーマはResponsiveを使用しています。
別のフォーラムテーマでも質問させていただいたのですが、もしかしたらカテゴリ違いかと思いこちらでも質問させていただきます。
ttp://ja.forums.wordpress.org/topic/41354?replies=2トップページにブログ投稿の最新記事を1件のみ全文表示させたいのですが、
思うようにできず困っています。
なお、通常のブログページには3件分表示されるように設定しています。今使用しているテーマだとトップページがindex.php、ブログの記事一覧がhome.phpなので、home.phpの中身をindex.phpにまるごと書き写し、以下の一文を加えて試しました。
<?php query_posts('posts_per_page=1'); ?>
すると最新の投稿記事は表示できたのですが、今度はトップページの記事がループしてしまいます。
どの部分をどう変更すればいいのかがわからず手詰まり状態です。
解決策がお分かりになるようでしたらご教授ください。以下がindex.phpに記載したhome.php内のコードです。
<?php get_template_part( 'loop-header' ); ?> <?php query_posts('posts_per_page=1'); ?> <?php if( have_posts() ) : ?> <?php while( have_posts() ) : the_post(); ?> <?php responsive_entry_before(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?> > <div class="grid col-460t"> <?php responsive_entry_top(); ?> <?php get_template_part( 'post-meta' ); ?> <div class="post-entry"> <?php if( has_post_thumbnail() ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail(); ?> </a> <?php endif; ?> <?php the_content( __( 'Read more ›', 'responsive' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="pagination">' . __( 'Pages:', 'responsive' ), 'after' => '</div>' ) ); ?> </div> </div> <!-- end of .post-entry --> <?php get_template_part( 'post-data' ); ?> <?php responsive_entry_bottom(); ?> </div><!-- end of #post-<?php the_ID(); ?> --> <?php responsive_entry_after(); ?> <?php endwhile; get_template_part( 'loop-nav' ); else : get_template_part( 'loop-no-posts' ); endif; ?>
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「トップページにブログの新着記事を全文表示させたい」には新たに返信することはできません。