title: Adding Pagination to Wordpress query for categories
body: <p>I am trying to add pagination to a custom category list I have for a website gallery using WordPress. I have tried to follow a few guides but unable to add the paging function to my query. I have added my current queries.
  Any help would be appreciated.</p>
  
  <pre><code>&lt;?php
  
              global $paged;
              $curpage = $page ? $paged :1;
  
              $args2 = array(
                  'taxonomy' =&gt; 'media-category',
                  //'parent' =&gt; '5',
                  'child_of' =&gt; 7,
                  'orderby' =&gt; 'date',
                  'order' =&gt; 'ASC',
                  'hide_empty' =&gt; 0,
                  'number' =&gt; 99,
                  'posts_per_page' =&gt; 3,
                  'paged' =&gt; $paged,
              );
              ?&gt;
              &lt;ul class="gallery-list small-block-grid-1 medium-block-grid-2 large-block-grid-3"&gt;
                  &lt;?php
                  $categories = get_categories($args2);
                  foreach ($categories as $category) {
  
                      $args = array(
                          'post_type' =&gt; 'attachment',
                          'post_status' =&gt; 'any',
                          'posts_per_archive_page' =&gt; -1,
                          'tax_query' =&gt; array(
                              array(
                                  'taxonomy' =&gt; 'media-category',
                                  'field' =&gt; 'slug',
                                  'terms' =&gt; array($category-&gt;name, 'featured'),
                                  'operator' =&gt; 'AND',
                              ),
                          ),
                      );
                      $custom_query = new WP_Query($args);
                      ?&gt;
                      &lt;?php while ($custom_query-&gt;have_posts()) : $custom_query-&gt;the_post(); ?&gt;
  </code></pre>