Guest User

Untitled

a guest
Jan 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /*
  2. ~The Most Base~
  3. ---------------
  4. */
  5. get_permalink() // постоянная ссылка
  6.  
  7. /*
  8. ~Pagination~
  9. ------------
  10. */
  11. // Simple Pagination
  12. next_posts_link( '<< Older Posts' );
  13. previous_posts_link( 'Newer Posts >>' );
  14.  
  15. // Simple Pagination with Title
  16. next_posts_link( '<span>Older Posts</span><h3>%link</h3>', '%title', false );
  17. previous_posts_link( '<span>Newer Posts</span><h3>%link</h3>', '%title', false );
  18.  
  19. // Numeric Pagination
  20. echo paginate_links();
  21.  
  22. /*
  23. ~Show Posts of Certain Category~
  24. */
  25. // for example of category 'about'
  26. // (if see ** - delete line if don't need pagination)
  27. $currentPage = get_query_var( 'paged' ); //**
  28.  
  29. $aboutPosts = new WP_Query( array(
  30. 'category_name' => 'about',
  31. 'posts_per_page' => 3,
  32. 'paged' => $paged //**
  33. ) );
  34.  
  35. <?php
  36. if( $aboutPosts->have_posts() ):
  37. while( $aboutPosts->have_posts() ):
  38. $aboutPosts->the_post();
  39. ?>
  40. <li>
  41. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  42. </li>
  43. <?php
  44. endwhile;
  45.  
  46. echo paginate_links( array(
  47. 'total' => $aboutPosts->max_num_pages //**
  48. ) );
  49.  
  50. //previous_posts_link(); //**
  51. //next_posts_link( 'Next Page', $aboutPosts->max_num_pages ); //**
  52.  
  53. endif;
  54. ?>
Add Comment
Please, Sign In to add comment