私も内容を理解していないのでかなり乱暴ですが下記をそのままコピペしちゃってください。
もちろんWP_Queryのクエリ呼び出しはそれぞれ指定したい投稿タイプ名にしたりしてください。
あと、ここの表示件数とWPの管理画面からの設定>表示設定の表示件数は合わせておきましょう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;//現在のページ送り番号を取得する $the_query = new WP_Query( array( 'post_status' => 'publish', 'post_type' => 'post', //投稿タイプ名 'paged' => $paged, 'posts_per_page' => 10, // 表示件数 ) ); ?> <?php if ($the_query->have_posts()) :?> <?php while ($the_query->have_posts()) : $the_query->the_post();?> <li><a href="<?php the_permalink(); ?>"> <div> <p class="day"><?php the_time('Y年m月d日') ?><i class="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></i></p> <p class="ttl"><?php the_title(); ?></p> </div> </a></li> <?php endwhile;?> <?php endif;?> <div class="pager_group clearfix"> <div class="pager"> <?php global $wp_rewrite; $paginate_base = get_pagenum_link(1); if (strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()) { $paginate_format = ''; $paginate_base = add_query_arg('paged', '%#%'); } else { $paginate_format = (substr($paginate_base, -1 ,1) == '/' ? '' : '/') . user_trailingslashit('page/%#%/', 'paged');; $paginate_base .= '%_%'; } echo paginate_links( array( 'base' => $paginate_base, 'format' => $paginate_format, 'total' => $wp_query->max_num_pages, 'mid_size' => 5, 'prev_text' => '‹',//ページ送りの名前 'next_text' => '›',//ページ送りの名前 'current' => ($paged ? $paged : 1), )); ?> </div> |