0

So the site I'm building has a few different archives pages. For the newest one I'm building, I tried to copy the archive.php I've got:

page-archives.php:

<?php get_header(); ?>

<section role="main" class="main">

    <h1>Archives</h1>

    <?php get_template_part('inc/loops/default','default-loop'); ?>

    <?php custom_pagination(); ?>

</section>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

inc/loops/default.php:

<?php

global $query_string;
$results = new WP_Query($query_string);

if ($results->have_posts()) :
    while ($results->have_posts()) :
        $results->the_post();
                    // DO STUFF HERE.
             endwhile;
    endif;

?>

And the custom_pagination function in functions.php:

function custom_pagination() {
    global $wp_query;
    $big = 999999999;
    echo paginate_links(array(
        'base' => str_replace($big, '%#%', get_pagenum_link($big)),
        'format' => '?paged=%#%',
        'current' => max(1, get_query_var('paged')),
        'total' => $wp_query->max_num_pages,
        'type' => 'list'
    ));
 }

Whenever I do global $query_string or global $wp_query, it thinks the query is for the Archives page (which it is) and I'm not sure how to break out of that.

I can work around that by putting the loop directly in the page-archives.php without $query_string and call paginate_links() instead of calling it's wrapper, but I'd rather not do that.

Also, I have an archive.php which is basically this, but I can't figure out how to get it to work for all posts. I need to answer this question anyways for a few other custom archives.

Belladonna
  • 111
  • 1
  • 5

0 Answers0