固定ページでのサブループWP_Queryでpost per pageの値より記事数が少ないと記事が表示されないのはなんで?
解決策は?
<?php $paged = get_query_var('paged') ? get_query_var('paged'):1; $args2 = array('posts_per_page' => 16, 'post__in' => $favorites, 'paged' => $paged); $the_query2 = new WP_Query($args2); $n=1; ?> <div class="mypostlist"> <?php if($the_query2 -> have_posts()) : while($the_query2 -> have_posts()) : $the_query2 -> the_post(); ?> <div class="aida2"> <?php the_title(); ?><br> <?php echo $n ;?> <?php if(has_post_thumbnail()): ?> <a href="<?php the_permalink() ?>"> <?php the_post_thumbnail('index_thumbnail',array('class' => 'forsize')); ?> </a> <?php else: ?> <a href="<?php the_permalink() ?>"> <img src="<?php echo get_stylesheet_directory_uri(); ?>/no-image.png" class="ichiran" > </a> <?php endif; ?> <?php $n++; ?> <br> <dl> <dt> <?php the_time('Y.m.d') ?> <?php the_tags() ?> </dt> </dl> </div> <?php endwhile; ?> <?php else: ?> <p>お気に入りがありません</p> <?php endif; ?> </div> <?php wp_reset_postdata(); ?> <?php if (function_exists('pagination')) { $GLOBALS['wp_query']->max_num_pages = $the_query->max_num_pages; $max_num_pages = $the_query->max_num_pages; pagination($max_num_pages); } ?> コード
回答2件
あなたの回答
tips
プレビュー