Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <?php
- $args = array (
- 'category__in' => array('1','2','3','4'), // カテゴリのIDを記入する
- 'order' => 'DESC', // 記事の並び順 昇順(ASC)、降順(DESC)
- 'paged' => $paged,
- 'post_per_page' => 10, //表示する記事の数
- );
- $paged = (int) get_query_var('paged');
- $the_query = new WP_Query( $args ); ?>
- <?php if( $the_query -> have_posts() ): while ( $the_query -> have_posts()): $the_query -> the_post(); ?>
- <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
- <?php endwhile; endif; ?>
- </ul>
- // ページネーションを表示
- <?php
- if ($the_query->max_num_pages > 1){
- echo paginate_links(
- array(
- 'base' => get_pagenum_link(1).'%_%',
- 'format' => 'page/%#%/',
- 'current' => max(1, $paged),
- 'total' => $the_query->max_num_pages,
- 'prev_next' => true,
- 'prev_text' => '« 前へ',
- 'next_text' => '次へ »',
- )
- );
- }
- wp_reset_postdata();
- ?>
Add Comment
Please, Sign In to add comment