bananamariap

Pagination

May 19th, 2021 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. <?php
  2. $paged = get_query_var('paged') ? get_query_var('paged') : 1;
  3. $args = array(
  4. 'post_type' => array( 'video' ),
  5. 'post_status' => array( 'publish' ),
  6. 'posts_per_page' => 5,
  7. 'paged'=>$paged
  8. );
  9.  
  10. $query = new WP_Query( $args );
  11. ?>
  12.  
  13. <div class="webinars-container">
  14. <div class="webinar-items">
  15. <h2>Latest Webinars</h2>
  16. <?php
  17.  
  18. if ( $query->have_posts() ) {
  19. while ( $query->have_posts() ) { $query->the_post();
  20.  
  21. ?>
  22. <div class="webinar-item">
  23. <div class="video-link">
  24. <?php
  25. $media = rwmb_meta( 'mb_video_link', get_the_ID() );
  26. echo $media;
  27. ?>
  28. </div>
  29. <div class="video-text">
  30. <h3 class="video-title"><?php echo get_the_title(); ?></h3>
  31.  
  32. <p class="video-desc">
  33. <?php
  34. $desc = rwmb_meta( 'mb_video_description', get_the_ID() );
  35. echo apply_filters('the_content', $desc );
  36. ?>
  37. </p>
  38. </div>
  39. </div>
  40. <?php }
  41. echo '<div class="pagination" style="text-align:center; padding: 30px">';
  42. $big = 999999999; // need an unlikely integer
  43. echo paginate_links( array(
  44. 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
  45. 'format' => '?paged=%#%',
  46. 'current' => max( 1, get_query_var('paged') ),
  47. 'total' => $query->max_num_pages
  48. ) );
  49. echo '</div>';
  50. } else { ?>
  51. <h3>No videos found</h3>
  52. <?php }
  53. // Restore original Post Data
  54. wp_reset_postdata();
  55. ?>
  56.  
  57. </div>
Add Comment
Please, Sign In to add comment