title: Pagination Solutions for multiple queries with multiple tabs Wordpress
body: <p>Hey guys so I have a projects page on our website that utilizes tabs to separate multiple different project types across different tabs. Each tab runs its own query   by category, ordering the projects in that category by date and displaying: The title, a date, views, author, a small extract of the post and a featured image. </p>
  
  <p>The problem now is that I have too many posts per tab and you have to scroll down a long way to see older projects. What is the best solution for breaking each project post by category into pages of 4 posts. Is a better solution to run a single loop, separate the projects into other tabs by category and the paginate the page? Or is there a more eloquent solution?</p>
  
  <p>Here is my main Project page with tabs:</p>
  
  <pre><code>          &lt;div id="categoryTabs"&gt;
              &lt;ul id="news_style1_tabs" class="tabs"&gt;
                  &lt;li&gt;&lt;a href="#mining"&gt;Mining&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#ong"&gt;Oil &amp; Gas&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#energy"&gt;Energy&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#infs"&gt;Infastructure&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#global"&gt;Global&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
  
  &lt;section id="news_style1_body" class="news_body"&gt; 
  
  &lt;div class="tab_all" id="mining"&gt;
  &lt;?php get_template_part('page-projectsTabs-mining'); ?&gt;
  &lt;/div&gt;
  
  &lt;div class="tab_all" id="ong"&gt;
  &lt;?php get_template_part('page-projectsTabs-ong'); ?&gt;
  &lt;/div&gt;
  
   &lt;div class="tab_all" id="energy"&gt;
  &lt;?php get_template_part('page-projectsTabs-energy'); ?&gt;
  &lt;/div&gt;
  
   &lt;div class="tab_all" id="infs"&gt;
  &lt;?php get_template_part('page-projectsTabs-infs'); ?&gt;
  &lt;/div&gt;
   &lt;div class="tab_all" id="global"&gt;
  &lt;?php get_template_part('page-projectsTabs-glob'); ?&gt;
  &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>and here is an example of one of the tabs with a category</p>
  
  <pre><code>&lt;?php
  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $args_mining = array(   'post_type'     =&gt; 'projects', 
      'status'        =&gt; 'published', 
      'category_name'     =&gt; 'Mining',
      'posts_per_page'=&gt; 4,
      'orderby'   =&gt; 'post_date',
      'order'         =&gt; 'DESC'
  );
  $get_mining = new WP_Query($args_mining);
  if($get_mining-&gt;have_posts()){
      while($get_mining-&gt;have_posts()) : $get_mining-&gt;the_post(); 
      $image = wp_get_attachment_image(get_post_thumbnail_id($get_mining-&gt;ID),'home-feature');?&gt;
  
                  &lt;article&gt;
                    &lt;div class="pic"&gt;&lt;a href="&lt;?php the_permalink();?&gt;" class="w_hover img-link img-wrap"&gt;&lt;?php echo $image; ?&gt;&lt;span class="link-gallery"&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt;
                    &lt;h3&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;
                    &lt;ul class="icons"&gt;
                      &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" class="post_date"&gt;&lt;?php echo get_the_time('d M, Y', $get_mining);?&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" class="post_views"&gt;&lt;?php echo get_post_meta(get_the_ID(),'views',true);?&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" class="post_submitted"&gt;&lt;?php echo get_post_meta(get_the_ID(),'Author',true);?&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="" class="comments_count"&gt;&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                     &lt;div class="text"&gt;&lt;?php echo get_excerpt(900,$get_mining); ?&gt;&lt;/div&gt;
                  &lt;/article&gt;
  
  &lt;?php endwhile;
  }?&gt;
  &lt;?php wp_reset_postdata(); ?&gt;
  </code></pre>
  
  <p>Any help and advice will be good. Please note at the moment I have about 5 tabs</p>
  
  <p>EDIT 1: Added my Pagination Function in my functions.php</p>
  
  <p>Below is the code for pagination found in my functions.php</p>
  
  <pre><code> function custom_pagination($numpages = '', $pagerange = '', $paged='') {
  
    if (empty($pagerange)) {
      $pagerange = 2;
    }
  
    global $paged;
    if (empty($paged)) {
      $paged = 1;
    }
    if ($numpages == '') {
      global $wp_query;
      $numpages = $wp_query-&gt;max_num_pages;
          if(!$numpages) {
              $numpages = 1;
          }
  }
      //Check page number and store $pageUp and $pageDown appropriately
    if($paged == '1'){
      $pageDown = $paged + 1;
      $pageUp = $paged +2;
      $prev = get_previous_posts_page_link($pageDown);
      $next = get_next_posts_page_link($pageUp);
  
  
    }
    elseif(($paged &gt;= 2)&amp;&amp;(!$paged==$numpages)){
      $pageDown = $paged -1;
      $pagedUp = $paged +1;
      $prev = get_previous_posts_page_link();
      $next = get_next_posts_page_link();
    }
    elseif($paged == $numpages){
      $pageDown = $paged -2;
      $pageUp = $paged -1;
      $prev = get_previous_posts_page_link($pageDown);
      $next = get_next_posts_page_link($pageUp);
    }  
  
  
  
    $pagination_args = array(
      'base'            =&gt; get_pagenum_link(1) . '%_%',
      'format'          =&gt; 'page/%#%',
      'total'           =&gt; $numpages,
      'current'         =&gt; $paged,
      'show_all'        =&gt; False,
      'end_size'        =&gt; 1,
      'mid_size'        =&gt; $pagerange,
      'prev_next'       =&gt; False,
      'prev_text'       =&gt; __('&amp;laquo;'),
      'next_text'       =&gt; __('&amp;raquo;'),
      'type'            =&gt; 'plain',
      'add_args'        =&gt; false,
      'add_fragment'    =&gt; ''
    );
  
    $paginate_links = paginate_links($pagination_args);
  
    if ($paginate_links) {
  
      echo '&lt;div id ="nav_pages"&gt;'; 
      echo '&lt;div class="prev_first"&gt;&lt;/div&gt;'; 
          //echo '   &lt;a href="'.$paginate_links.'" class="next"&gt;Next&lt;/a&gt;';
          echo '&lt;div class="pages"';
          echo'&lt;ul&gt;';
          if($paged==1){      
              $pageDown = $paged + 1;
              $pageUp = $paged +2;
              $prev = get_next_posts_page_link();
              $next = get_next_posts_page_link();
              echo' &lt;li class="current"&gt;&lt;a href="" title=""&gt;'.$paged.'&lt;/a&gt;&lt;/li&gt;';
              echo'&lt;li&gt;&lt;a href="'.$prev.'" title="'.$prev.'"&gt;'.$pageDown.'&lt;/a&gt;&lt;/li&gt;';
              //echo'&lt;li&gt;&lt;a href="'.$next.'" title="'.$next.'"&gt;'.$pageUp.'&lt;/a&gt;&lt;/li&gt;';
              }
          elseif(($paged &gt;= 2)&amp;&amp;($paged!=$numpages)){
              $pageDown = $paged -1;
              $pageUp = $paged +1;
              $prev = get_previous_posts_page_link();
              $next = get_next_posts_page_link();
              echo'&lt;li&gt;&lt;a href="'.$prev.'" title="'.$prev.'"&gt;'.$pageDown.'&lt;/a&gt;&lt;/li&gt;';
              echo' &lt;li class="current"&gt;&lt;a href="" title=""&gt;'.$paged.'&lt;/a&gt;&lt;/li&gt;';
              echo'&lt;li&gt;&lt;a href="'.$next.'" title=""&gt;'.$pageUp.'&lt;/a&gt;&lt;/li&gt;';
          }
  
          elseif($paged==$numpages){
              $pageDown = $paged -2;
              $pageUp = $paged -1;
              $prev = get_previous_posts_page_link();
              $next = get_next_posts_page_link();
              echo'&lt;li&gt;&lt;a href="'.$prev.'" title="'.$prev.'"&gt;'.$pageUp.'&lt;/a&gt;&lt;/li&gt;';
              //echo'&lt;li&gt;&lt;a href="'.$next.'" title="'.$next.'"&gt;'.$pageUp.'&lt;/a&gt;&lt;/li&gt;';
              echo' &lt;li class="current"&gt;&lt;a href="" title=""&gt;'.$paged.'&lt;/a&gt;&lt;/li&gt;';
  
  
          }   
           //echo $paginate_links;
           echo '&lt;/ul&gt;';
            echo '&lt;div class="page_x_of_y"&gt;Page &lt;span&gt;' . $paged . '&lt;/span&gt; of &lt;span&gt;' . $numpages . '&lt;/span&gt;&lt;/div&gt; ';
  
          echo '&lt;/div&gt;';
    } 
  
  }
  
  //End of pagination
  </code></pre>