Guest User

Untitled

a guest
Dec 10th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <ul>
  2. <?php
  3. $args = array (
  4. 'category__in' => array('1','2','3','4'), // カテゴリのIDを記入する
  5. 'order' => 'DESC', // 記事の並び順 昇順(ASC)、降順(DESC)
  6. 'paged' => $paged,
  7. 'post_per_page' => 10, //表示する記事の数
  8. );
  9. $paged = (int) get_query_var('paged');
  10. $the_query = new WP_Query( $args ); ?>
  11. <?php if( $the_query -> have_posts() ): while ( $the_query -> have_posts()): $the_query -> the_post(); ?>
  12. <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
  13. <?php endwhile; endif; ?>
  14. </ul>
  15.  
  16. // ページネーションを表示
  17. <?php
  18. if ($the_query->max_num_pages > 1){
  19. echo paginate_links(
  20. array(
  21. 'base' => get_pagenum_link(1).'%_%',
  22. 'format' => 'page/%#%/',
  23. 'current' => max(1, $paged),
  24. 'total' => $the_query->max_num_pages,
  25. 'prev_next' => true,
  26. 'prev_text' => '« 前へ',
  27. 'next_text' => '次へ »',
  28. )
  29. );
  30. }
  31. wp_reset_postdata();
  32. ?>
Add Comment
Please, Sign In to add comment