記事一覧ページから3件だけ最新の記事をTOPに表示されたいのですが、条件分岐の設定が理解できていません。
WordPressの条件分岐の設定について教えてください。
記事ループは以下の通り作りました。
loop-blog.php
<?php wp_reset_query(); if ( is_home() ) { // ブログ投稿インデックスを表示中 query_posts('posts_per_page=3'); } else { query_posts('posts_per_page=10'); } ?> <?php query_posts('post_type=post&paged='.$paged); ?> <?php if (have_posts()): while (have_posts()): the_post(); ?> <div class="blog_list"> <a href="<?php the_permalink(); ?>"> <?php if (has_post_thumbnail()):?> <?php the_post_thumbnail('blogimg'); ?> <?php else:?> <img src="<?php echo get_template_directory_uri(); ?>/img/no-image.jpg"> <?php endif;?> <time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d(l)'); ?></time> <p><?php the_title();?><br><?php the_excerpt(); ?></p> </a> </div> <?php endwhile; endif; ?> <?php wp_reset_query(); ?> </div>
で、記事一覧のテンプレは
/* template Name: blogアーカイブのテンプレート */ get_header(); ?> <div id="page"> <div class="content_page"> <div class="bread"><p><a href="<?php echo home_url(); ?>">Home</a> < BLOG </p></div> <div class="content_page_top_image"><img src="<?php echo get_template_directory_uri(); ?>/img/xxx.png" alt=""> <div class="content_page_heading"> <h1>タイトル</h1> </div> </div> <section id="b-archive"> <?php get_template_part('loop','blog')?> </section> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
トップは、
front-page.phpの中に、
で表示させようとしています。
functions.phpで分岐させる方法も試しましたがダメでした。
ご教示ください。
回答1件
あなたの回答
tips
プレビュー