Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to append 2 variables from page 2 onwards in my loop.

This is my normal category page

www.example.com/category/news/

This is what I would like on pages: 2, 3, 4, 5 etc

www.example.com/category/news/page/2/?var1=one&var2=two

The Loop:

$args = array
(
   'category_name' => 'news',
   'posts_per_page' => 5,
   'paged' => $paged
);

$news_loop = new WP_Query($args);
while ($news_loop->have_posts()) : $news_loop->the_post();

    // posts

endwhile;
wp_pagenavi(array('query' => $news_loop)); ?>
share|improve this question
    
You haven't included the code that actually creates the links? That is a strange thing to leave out. –  s_ha_dum Feb 12 at 15:10
    
um, it's bog standard links created with the wp pagenavi plugin. I have added anywho. –  Keith Donegan Feb 12 at 15:26
1  
"Pagenavi" is a plugin and hence is not "standard"-- common maybe, but not standard. How did you expect anyone to know that this involved a plugin? –  s_ha_dum Feb 12 at 15:53
    
Jesus... It's the same as using 'previous post link', the pagination is not the problem! –  Keith Donegan Feb 12 at 15:58
    
First: Be nice. Second: The plugin creates the links. Maybe it's even responsible for creating rewrite structures. In short: Please edit your question and add a link to the plugin source. Thanks. –  kaiser Feb 12 at 16:05

1 Answer 1

Refer this: Paginate Codex

I can see that you are using custom query so you put this below and outside the while loop

<?php
        global $wp_query;
        $big = 999999999; // need an unlikely integer
        $args = array(
            'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
            'format' => '?page=%#%',
            'total' => $wp_query->max_num_pages,
            'current' => max( 1, get_query_var( 'paged') ),
            'show_all' => true,
            'end_size' => 1,
            'mid_size' => 2,
            'prev_next' => False,
            'prev_text' => __('&laquo; Previous'),
            'next_text' => __('Next &raquo;'),
            'type' => 'list',
            );
        echo paginate_links($args);
    ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.